]> sourceware.org Git - lvm2.git/commitdiff
lvmdbustest.py: Add func. _pv_scan
authorTony Asleson <tasleson@redhat.com>
Thu, 3 Oct 2019 21:11:18 +0000 (16:11 -0500)
committerTony Asleson <tasleson@redhat.com>
Wed, 30 Oct 2019 15:38:40 +0000 (10:38 -0500)
test/dbus/lvmdbustest.py

index 497a605ebfaf4f3bffbe39114f0cc5317786ff46..92e4331321e0f740e1bae6b6f347ba00e87377cc 100755 (executable)
@@ -1314,75 +1314,36 @@ class TestDbusService(unittest.TestCase):
                context = pyudev.Context()
                return context.list_devices(subsystem='block', MAJOR='8')
 
-       def test_pv_scan(self):
-               devices = TestDbusService._get_devices()
-
+       def _pv_scan(self, activate, cache, device_paths, major_minors):
                mgr = self._manager().Manager
+               return self.handle_return(
+                       mgr.PvScan(
+                               dbus.Boolean(activate),
+                               dbus.Boolean(cache),
+                               dbus.Array(device_paths, 's'),
+                               dbus.Array(major_minors, '(ii)'),
+                               dbus.Int32(g_tmo),
+                               EOD))
 
-               self.assertEqual(
-                       self.handle_return(
-                               mgr.PvScan(
-                                       dbus.Boolean(False),
-                                       dbus.Boolean(True),
-                                       dbus.Array([], 's'),
-                                       dbus.Array([], '(ii)'),
-                                       dbus.Int32(g_tmo),
-                                       EOD)), '/')
+       def test_pv_scan(self):
+               devices = TestDbusService._get_devices()
 
+               self.assertEqual(self._pv_scan(False, True, [], []), '/')
                self._check_consistency()
-               self.assertEqual(
-                       self.handle_return(
-                               mgr.PvScan(
-                                       dbus.Boolean(False),
-                                       dbus.Boolean(False),
-                                       dbus.Array([], 's'),
-                                       dbus.Array([], '(ii)'),
-                                       dbus.Int32(g_tmo),
-                                       EOD)), '/')
-
+               self.assertEqual(self._pv_scan(False, False, [], []), '/')
                self._check_consistency()
 
-               block_path = []
-               for d in devices:
-                       block_path.append(d.properties['DEVNAME'])
-
-               self.assertEqual(
-                       self.handle_return(
-                               mgr.PvScan(
-                                       dbus.Boolean(False),
-                                       dbus.Boolean(True),
-                                       dbus.Array(block_path, 's'),
-                                       dbus.Array([], '(ii)'),
-                                       dbus.Int32(g_tmo),
-                                       EOD)), '/')
-
+               block_path = [d.properties['DEVNAME'] for d in devices]
+               self.assertEqual(self._pv_scan(False, True, block_path, []), '/')
                self._check_consistency()
 
-               mm = []
-               for d in devices:
-                       mm.append((int(d.properties['MAJOR']), int(d.properties['MINOR'])))
-
-               self.assertEqual(
-                       self.handle_return(
-                               mgr.PvScan(
-                                       dbus.Boolean(False),
-                                       dbus.Boolean(True),
-                                       dbus.Array(block_path, 's'),
-                                       dbus.Array(mm, '(ii)'),
-                                       dbus.Int32(g_tmo),
-                                       EOD)), '/')
+               mm = [(int(d.properties['MAJOR']), int(d.properties['MINOR']))
+                               for d in devices]
 
+               self.assertEqual(self._pv_scan(False, True, block_path, mm), '/')
                self._check_consistency()
 
-               self.assertEqual(
-                       self.handle_return(
-                               mgr.PvScan(
-                                       dbus.Boolean(False),
-                                       dbus.Boolean(True),
-                                       dbus.Array([], 's'),
-                                       dbus.Array(mm, '(ii)'),
-                                       dbus.Int32(g_tmo),
-                                       EOD)), '/')
+               self.assertEqual(self._pv_scan(False, True, [], mm), '/')
                self._check_consistency()
 
        @staticmethod
This page took 0.042395 seconds and 5 git commands to generate.