[blivet:rhel7-master 2/3] Add a test file for DASD handling (#1070115)

mulhern amulhern at redhat.com
Mon Sep 8 17:27:26 UTC 2014


Related: rhbz#1070115

Signed-off-by: mulhern <amulhern at redhat.com>
---
 tests/devicelibs_test/dasd_test.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 tests/devicelibs_test/dasd_test.py

diff --git a/tests/devicelibs_test/dasd_test.py b/tests/devicelibs_test/dasd_test.py
new file mode 100644
index 0000000..033d207
--- /dev/null
+++ b/tests/devicelibs_test/dasd_test.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+import unittest
+
+import blivet.devicelibs.dasd as dasd
+
+class SanitizeTest(unittest.TestCase):
+
+    def testSanitize(self):
+        with self.assertRaises(ValueError):
+            dasd.sanitize_dasd_dev_input("")
+
+        # without a ., the whole value is assumed to be the device number
+        # and a bus number is prepended
+        dev = "1234abc"
+        self.assertEqual(dasd.sanitize_dasd_dev_input(dev), '0.0.' + dev)
+
+        # whatever is on the left side of the rightmost period is assumed to
+        # be the bus number
+        dev = "zed.1234abq"
+        self.assertEqual(dasd.sanitize_dasd_dev_input(dev), dev)
+
+        # the device number is padded on the left with 0s up to 4 digits
+        dev = "zed.abc"
+        self.assertEqual(dasd.sanitize_dasd_dev_input(dev), "zed.0abc")
+        dev = "abc"
+        self.assertEqual(dasd.sanitize_dasd_dev_input(dev), "0.0.0abc")
-- 
1.9.3



More information about the anaconda-patches mailing list