ceph-volume tests inventory should patch before using .get_devices()
authorAlfredo Deza <adeza@redhat.com>
Mon, 12 Nov 2018 17:56:42 +0000 (12:56 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 12 Nov 2018 20:01:42 +0000 (15:01 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 7ee7a59910c9837659419c235f669a53cc9f613c)

src/ceph-volume/ceph_volume/tests/test_inventory.py

index 655d613ac1c302db7fcab872dc930d864f37f69f..720c4b820c8bf975a0f87397b9de57b4cf845113 100644 (file)
@@ -2,24 +2,38 @@
 
 import pytest
 from ceph_volume.util.device import Devices
-from ceph_volume import sys_info
+
 
 @pytest.fixture
-def device_report_keys():
+def device_report_keys(device_info):
+    device_info(devices={
+        # example output of disk.get_devices()
+        '/dev/sdb': {'human_readable_size': '1.82 TB',
+                     'locked': 0,
+                     'model': 'PERC H700',
+                     'nr_requests': '128',
+                     'partitions': {},
+                     'path': '/dev/sdb',
+                     'removable': '0',
+                     'rev': '2.10',
+                     'ro': '0',
+                     'rotational': '1',
+                     'sas_address': '',
+                     'sas_device_handle': '',
+                     'scheduler_mode': 'cfq',
+                     'sectors': 0,
+                     'sectorsize': '512',
+                     'size': 1999844147200.0,
+                     'support_discard': '',
+                     'vendor': 'DELL'}
+    }
+ )
     report = Devices().json_report()[0]
     return list(report.keys())
 
 @pytest.fixture
-def device_sys_api_keys():
-    report = Devices().json_report()[0]
-    return list(report['sys_api'].keys())
-
-
-class TestInventory(object):
-
-    # populate sys_info with something; creating a Device instance will use
-    # this data
-    sys_info.devices = {
+def device_sys_api_keys(device_info):
+    device_info(devices={
         # example output of disk.get_devices()
         '/dev/sdb': {'human_readable_size': '1.82 TB',
                      'locked': 0,
@@ -40,6 +54,12 @@ class TestInventory(object):
                      'support_discard': '',
                      'vendor': 'DELL'}
     }
+ )
+    report = Devices().json_report()[0]
+    return list(report['sys_api'].keys())
+
+
+class TestInventory(object):
 
     expected_keys = [
         'path',