Fixes testcases that are broken due to change in sushy

Few of the testcases were broken as we are asserting sushy method which
got changed.

Change-Id: I05c9eee411cf586b5cfc0f4895ab1efc7d2c9b42
This commit is contained in:
Shivanand Tendulker 2019-11-15 00:47:32 -05:00 committed by Shivanand Tendulker
parent 28291c6647
commit 36f90a22d5
11 changed files with 103 additions and 89 deletions

View File

@ -33,7 +33,7 @@ class VirtualMediaCollectionTestCase(testtools.TestCase):
super(VirtualMediaCollectionTestCase, self).setUp()
self.conn = mock.MagicMock()
with open('proliantutils/tests/redfish/'
'json_samples/vmedia_collection.json', 'r') as f:
'json_samples/vmedia_collection.json') as f:
self.conn.get.return_value.json.return_value = (
json.loads(f.read()))
@ -59,10 +59,10 @@ class VirtualMediaTestCase(testtools.TestCase):
super(VirtualMediaTestCase, self).setUp()
self.conn = mock.MagicMock()
with open('proliantutils/tests/redfish/'
'json_samples/vmedia.json', 'r') as f:
vmedia_json = json.loads(f.read())
'json_samples/vmedia.json') as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = vmedia_json[
self.conn.get.return_value.json.return_value = self.json_doc[
'default']
self.vmedia_inst = virtual_media.VirtualMedia(
@ -70,7 +70,7 @@ class VirtualMediaTestCase(testtools.TestCase):
redfish_version='1.0.2')
def test__parse_attributes(self):
self.vmedia_inst._parse_attributes()
self.vmedia_inst._parse_attributes(self.json_doc['default'])
self.assertEqual(['cd', 'dvd'], self.vmedia_inst.media_types)
self.assertEqual(False, self.vmedia_inst.inserted)
@ -78,7 +78,7 @@ class VirtualMediaTestCase(testtools.TestCase):
self.vmedia_inst.json.pop('Oem')
self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute Oem/Hpe/Actions',
self.vmedia_inst._parse_attributes)
self.vmedia_inst._parse_attributes, self.json_doc)
def test__get_action_element_insert(self):
value = self.vmedia_inst._get_action_element('insert')

View File

@ -29,14 +29,15 @@ class HPEArrayControllerTestCase(testtools.TestCase):
'array_controller.json')
with open(array_controller_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
path = ("/redfish/v1/Systems/1/SmartStorage/ArrayControllers")
self.sys_stor = array_controller.HPEArrayController(
self.conn, path, redfish_version='1.0.2')
self.conn, path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_stor._parse_attributes()
self.sys_stor._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor.redfish_version)
self.assertEqual('HPE Smart Array P408i-a SR Gen10',
self.sys_stor.model)
@ -86,13 +87,14 @@ class HPEArrayControllerCollectionTestCase(testtools.TestCase):
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'array_controller_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_stor_col = array_controller.HPEArrayControllerCollection(
self.conn, '/redfish/v1/Systems/1/SmartStorage/ArrayControllers',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
self.sys_stor_col._parse_attributes()
self.sys_stor_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor_col.redfish_version)
self.assertEqual('HpeSmartStorageArrayControllers',
self.sys_stor_col.name)
@ -106,7 +108,7 @@ class HPEArrayControllerCollectionTestCase(testtools.TestCase):
mock_eth.assert_called_once_with(
self.sys_stor_col._conn,
'/redfish/v1/Systems/1/SmartStorage/ArrayControllers/0',
redfish_version=self.sys_stor_col.redfish_version)
self.sys_stor_col.redfish_version, None)
@mock.patch.object(array_controller, 'HPEArrayController', autospec=True)
def test_get_members(self, mock_eth):
@ -114,7 +116,7 @@ class HPEArrayControllerCollectionTestCase(testtools.TestCase):
path = ("/redfish/v1/Systems/1/SmartStorage/ArrayControllers/0")
calls = [
mock.call(self.sys_stor_col._conn, path,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -27,9 +27,10 @@ class DriveTestCase(testtools.TestCase):
super(DriveTestCase, self).setUp()
self.conn = mock.Mock()
drive_file = 'proliantutils/tests/redfish/json_samples/drive.json'
with open(drive_file, 'r') as f:
dr_json = json.loads(f.read())
self.conn.get.return_value.json.return_value = dr_json['drive1']
with open(drive_file) as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = (
self.json_doc['drive1'])
drive_path = ("/redfish/v1/Systems/437XR1138R2/Storage/1/"
"Drives/35D38F11ACEF7BD3")
@ -37,7 +38,7 @@ class DriveTestCase(testtools.TestCase):
self.conn, drive_path, redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_drive._parse_attributes()
self.sys_drive._parse_attributes(self.json_doc['drive1'])
self.assertEqual('1.0.2', self.sys_drive.redfish_version)
self.assertEqual(899527000000, self.sys_drive.capacity_bytes)
self.assertEqual(constants.PROTOCOL_SAS, self.sys_drive.protocol)

View File

@ -27,16 +27,17 @@ class HPELogicalDriveTestCase(testtools.TestCase):
self.conn = mock.Mock()
logical_file = ('proliantutils/tests/redfish/json_samples/'
'logical_drive.json')
with open(logical_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
with open(logical_file) as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
path = ("/redfish/v1/Systems/1/SmartStorage/"
"ArrayControllers/0/LogicalDrives")
self.sys_stor = logical_drive.HPELogicalDrive(
self.conn, path, redfish_version='1.0.2')
self.conn, path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_stor._parse_attributes()
self.sys_stor._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor.redfish_version)
@ -46,15 +47,16 @@ class HPELogicalDriveCollectionTestCase(testtools.TestCase):
super(HPELogicalDriveCollectionTestCase, self).setUp()
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'logical_drive_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
'logical_drive_collection.json') as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_stor_col = logical_drive.HPELogicalDriveCollection(
self.conn, ('/redfish/v1/Systems/1/SmartStorage/'
'ArrayControllers/0/LogicalDrives'),
redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_stor_col._parse_attributes()
self.sys_stor_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor_col.redfish_version)
self.assertEqual('HpeSmartStorageLogicalDrives',
self.sys_stor_col.name)
@ -73,7 +75,7 @@ class HPELogicalDriveCollectionTestCase(testtools.TestCase):
self.sys_stor_col._conn,
('/redfish/v1/Systems/1/SmartStorage/ArrayControllers/0/'
'LogicalDrives/1'),
redfish_version=self.sys_stor_col.redfish_version)
self.sys_stor_col.redfish_version, None)
@mock.patch.object(logical_drive, 'HPELogicalDrive', autospec=True)
def test_get_members(self, mock_eth):
@ -84,9 +86,9 @@ class HPELogicalDriveCollectionTestCase(testtools.TestCase):
"0/LogicalDrives/2")
calls = [
mock.call(self.sys_stor_col._conn, path1,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
mock.call(self.sys_stor_col._conn, path2,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -27,17 +27,18 @@ class HPEPhysicalDriveTestCase(testtools.TestCase):
self.conn = mock.Mock()
logical_file = ('proliantutils/tests/redfish/json_samples/'
'disk_drive.json')
with open(logical_file, 'r') as f:
dr_json = json.loads(f.read())
self.conn.get.return_value.json.return_value = dr_json['drive1']
with open(logical_file) as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = (
self.json_doc['drive1'])
path = ("/redfish/v1/Systems/1/SmartStorage/"
"ArrayControllers/0/DiskDrives")
self.sys_stor = physical_drive.HPEPhysicalDrive(
self.conn, path, redfish_version='1.0.2')
self.conn, path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_stor._parse_attributes()
self.sys_stor._parse_attributes(self.json_doc['drive1'])
self.assertEqual('1.0.2', self.sys_stor.redfish_version)
self.assertEqual(600, self.sys_stor.capacity_gb)
self.assertEqual('KWGER73R', self.sys_stor.serial_number)
@ -50,14 +51,15 @@ class HPEPhysicalDriveCollectionTestCase(testtools.TestCase):
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'disk_drive_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_stor_col = physical_drive.HPEPhysicalDriveCollection(
self.conn, ('/redfish/v1/Systems/1/SmartStorage/'
'ArrayControllers/0/DiskDrives'),
redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_stor_col._parse_attributes()
self.sys_stor_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor_col.redfish_version)
self.assertEqual('HpeSmartStorageDiskDrives',
self.sys_stor_col.name)
@ -76,7 +78,7 @@ class HPEPhysicalDriveCollectionTestCase(testtools.TestCase):
self.sys_stor_col._conn,
('/redfish/v1/Systems/1/SmartStorage/ArrayControllers/0/'
'DiskDrives/3'),
redfish_version=self.sys_stor_col.redfish_version)
self.sys_stor_col.redfish_version, None)
@mock.patch.object(physical_drive, 'HPEPhysicalDrive', autospec=True)
def test_get_members(self, mock_eth):
@ -87,9 +89,9 @@ class HPEPhysicalDriveCollectionTestCase(testtools.TestCase):
"0/DiskDrives/4")
calls = [
mock.call(self.sys_stor_col._conn, path,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
mock.call(self.sys_stor_col._conn, path2,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -27,21 +27,21 @@ class SimpleStorageTestCase(testtools.TestCase):
self.conn = mock.Mock()
simple_file = ('proliantutils/tests/redfish/json_samples/'
'simple_storage.json')
with open(simple_file, 'r') as f:
self.simple_json = json.loads(f.read())
self.conn.get.return_value.json.return_value = self.simple_json
with open(simple_file) as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
simple_path = ("/redfish/v1/Systems/437XR1138R2/SimpleStorage/1")
self.sys_simple = simple_storage.SimpleStorage(
self.conn, simple_path, redfish_version='1.0.2')
self.conn, simple_path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_simple._parse_attributes()
self.sys_simple._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_simple.redfish_version)
self.assertEqual('1', self.sys_simple.identity)
self.assertEqual('Simple Storage Controller', self.sys_simple.name)
self.assertEqual('System SATA', self.sys_simple.description)
self.assertEqual(self.simple_json.get('Devices'),
self.assertEqual(self.json_doc.get('Devices'),
self.sys_simple.devices)
def test_maximum_size_bytes(self):
@ -61,13 +61,14 @@ class SimpleStorageCollectionTestCase(testtools.TestCase):
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'simple_storage_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_simple_col = simple_storage.SimpleStorageCollection(
self.conn, '/redfish/v1/Systems/437XR1138R2/SimpleStorage',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
self.sys_simple_col._parse_attributes()
self.sys_simple_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_simple_col.redfish_version)
self.assertEqual('Simple Storage Collection',
self.sys_simple_col.name)
@ -81,7 +82,7 @@ class SimpleStorageCollectionTestCase(testtools.TestCase):
mock_simple.assert_called_once_with(
self.sys_simple_col._conn,
'/redfish/v1/Systems/437XR1138R2/SimpleStorage/1',
redfish_version=self.sys_simple_col.redfish_version)
self.sys_simple_col.redfish_version, None)
@mock.patch.object(simple_storage, 'SimpleStorage', autospec=True)
def test_get_members(self, mock_simple):
@ -89,7 +90,7 @@ class SimpleStorageCollectionTestCase(testtools.TestCase):
simple_path = ("/redfish/v1/Systems/437XR1138R2/SimpleStorage/1")
calls = [
mock.call(self.sys_simple_col._conn, simple_path,
redfish_version=self.sys_simple_col.redfish_version),
self.sys_simple_col.redfish_version, None),
]
mock_simple.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -29,14 +29,15 @@ class HPESmartStorageTestCase(testtools.TestCase):
storage_file = ('proliantutils/tests/redfish/json_samples'
'/smart_storage.json')
with open(storage_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
path = ("/redfish/v1/Systems/1/SmartStorage")
self.sys_stor = smart_storage.HPESmartStorage(
self.conn, path, redfish_version='1.0.2')
self.conn, path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_stor._parse_attributes()
self.sys_stor._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor.redfish_version)
def test_array_controllers(self):

View File

@ -26,22 +26,22 @@ class StorageTestCase(testtools.TestCase):
super(StorageTestCase, self).setUp()
self.conn = mock.Mock()
storage_file = 'proliantutils/tests/redfish/json_samples/storage.json'
with open(storage_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.stor_json = self.conn.get.return_value.json.return_value
with open(storage_file) as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
path = ("/redfish/v1/Systems/437XR1138R2/Storage/1")
self.sys_stor = storage.Storage(
self.conn, path, redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_stor._parse_attributes()
self.sys_stor._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor.redfish_version)
self.assertEqual('1', self.sys_stor.identity)
self.assertEqual('Local Storage Controller', self.sys_stor.name)
self.assertEqual('Integrated RAID Controller',
self.sys_stor.description)
self.assertEqual(self.stor_json.get('Drives'),
self.assertEqual(self.json_doc.get('Drives'),
self.sys_stor.drives)
def test_volumes(self):
@ -149,14 +149,15 @@ class StorageCollectionTestCase(testtools.TestCase):
super(StorageCollectionTestCase, self).setUp()
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'storage_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
'storage_collection.json') as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_stor_col = storage.StorageCollection(
self.conn, '/redfish/v1/Systems/437XR1138R2/Storage',
redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_stor_col._parse_attributes()
self.sys_stor_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_stor_col.redfish_version)
self.assertEqual('Storage Collection',
self.sys_stor_col.name)
@ -170,7 +171,7 @@ class StorageCollectionTestCase(testtools.TestCase):
mock_eth.assert_called_once_with(
self.sys_stor_col._conn,
('/redfish/v1/Systems/437XR1138R2/Storage/1'),
redfish_version=self.sys_stor_col.redfish_version)
self.sys_stor_col.redfish_version, None)
@mock.patch.object(storage, 'Storage', autospec=True)
def test_get_members(self, mock_eth):
@ -178,7 +179,7 @@ class StorageCollectionTestCase(testtools.TestCase):
path = ("/redfish/v1/Systems/437XR1138R2/Storage/1")
calls = [
mock.call(self.sys_stor_col._conn, path,
redfish_version=self.sys_stor_col.redfish_version),
self.sys_stor_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -27,14 +27,15 @@ class VolumeTestCase(testtools.TestCase):
self.conn = mock.Mock()
vol_file = 'proliantutils/tests/redfish/json_samples/volume.json'
with open(vol_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
vol_path = ("/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/1")
self.sys_vol = volume.Volume(
self.conn, vol_path, redfish_version='1.0.2')
self.conn, vol_path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_vol._parse_attributes()
self.sys_vol._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_vol.redfish_version)
self.assertEqual('1', self.sys_vol.identity)
self.assertEqual(899527000000, self.sys_vol.capacity_bytes)
@ -47,13 +48,14 @@ class VolumeCollectionTestCase(testtools.TestCase):
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'volume_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_vol_col = volume.VolumeCollection(
self.conn, '/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
self.sys_vol_col._parse_attributes()
self.sys_vol_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_vol_col.redfish_version)
self.assertEqual('Storage Volume Collection',
self.sys_vol_col.name)
@ -67,7 +69,7 @@ class VolumeCollectionTestCase(testtools.TestCase):
mock_vol.assert_called_once_with(
self.sys_vol_col._conn,
('/redfish/v1/Systems/437XR1138R2/Volumes/1'),
redfish_version=self.sys_vol_col.redfish_version)
self.sys_vol_col.redfish_version, None)
@mock.patch.object(volume, 'Volume', autospec=True)
def test_get_members(self, mock_vol):
@ -75,7 +77,7 @@ class VolumeCollectionTestCase(testtools.TestCase):
vol_path = ("/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/1")
calls = [
mock.call(self.sys_vol_col._conn, vol_path,
redfish_version=self.sys_vol_col.redfish_version),
self.sys_vol_col.redfish_version, None),
]
mock_vol.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -30,16 +30,16 @@ class EthernetInterfaceTestCase(testtools.TestCase):
eth_file = ('proliantutils/tests/redfish/json_samples/'
'ethernet_interface.json')
with open(eth_file, 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(
f.read())['default']
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc['default']
eth_path = ("/redfish/v1/Systems/437XR1138R2/EthernetInterfaces/"
"12446A3B0411")
self.sys_eth = ethernet_interface.EthernetInterface(
self.conn, eth_path, redfish_version='1.0.2')
self.conn, eth_path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_eth._parse_attributes()
self.sys_eth._parse_attributes(self.json_doc['default'])
self.assertEqual('1.0.2', self.sys_eth.redfish_version)
self.assertEqual('1', self.sys_eth.identity)
self.assertEqual('Ethernet Interface', self.sys_eth.name)
@ -60,13 +60,14 @@ class EthernetInterfaceCollectionTestCase(testtools.TestCase):
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'ethernet_interface_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_eth_col = ethernet_interface.EthernetInterfaceCollection(
self.conn, '/redfish/v1/Systems/437XR1138R2/EthernetInterfaces',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
self.sys_eth_col._parse_attributes()
self.sys_eth_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_eth_col.redfish_version)
self.assertEqual('Ethernet Interface Collection',
self.sys_eth_col.name)
@ -83,7 +84,7 @@ class EthernetInterfaceCollectionTestCase(testtools.TestCase):
self.sys_eth_col._conn,
('/redfish/v1/Systems/437XR1138R2/EthernetInterfaces/'
'12446A3B0411'),
redfish_version=self.sys_eth_col.redfish_version)
self.sys_eth_col.redfish_version, None)
@mock.patch.object(ethernet_interface, 'EthernetInterface', autospec=True)
def test_get_members(self, mock_eth):
@ -92,7 +93,7 @@ class EthernetInterfaceCollectionTestCase(testtools.TestCase):
"12446A3B0411")
calls = [
mock.call(self.sys_eth_col._conn, eth_path,
redfish_version=self.sys_eth_col.redfish_version),
self.sys_eth_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -28,15 +28,15 @@ class PCIDeviceTestCase(testtools.TestCase):
self.conn = mock.Mock()
pci_file = 'proliantutils/tests/redfish/json_samples/pci_device.json'
with open(pci_file, 'r') as f:
self.conn.get.return_value.json.return_value = (
json.loads(f.read()))
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
pci_path = "/redfish/v1/Systems/1/PCIDevices/1"
self.sys_pci = pci_device.PCIDevice(
self.conn, pci_path, redfish_version='1.0.2')
self.conn, pci_path, '1.0.2', None)
def test__parse_attributes(self):
self.sys_pci._parse_attributes()
self.sys_pci._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_pci.redfish_version)
self.assertEqual('1', self.sys_pci.identity)
self.assertEqual(1, self.sys_pci.nic_capacity)
@ -48,14 +48,15 @@ class PCIDeviceCollectionTestCase(testtools.TestCase):
super(PCIDeviceCollectionTestCase, self).setUp()
self.conn = mock.Mock()
with open('proliantutils/tests/redfish/json_samples/'
'pci_device_collection.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
'pci_device_collection.json') as f:
self.json_doc = json.load(f)
self.conn.get.return_value.json.return_value = self.json_doc
self.sys_pci_col = pci_device.PCIDeviceCollection(
self.conn, '/redfish/v1/Systems/1/PCIDevices',
redfish_version='1.0.2')
def test__parse_attributes(self):
self.sys_pci_col._parse_attributes()
self.sys_pci_col._parse_attributes(self.json_doc)
self.assertEqual('1.0.2', self.sys_pci_col.redfish_version)
self.assertEqual('PciDevices', self.sys_pci_col.name)
pci_path = ('/redfish/v1/Systems/1/PCIDevices/1',
@ -69,7 +70,7 @@ class PCIDeviceCollectionTestCase(testtools.TestCase):
mock_pci.assert_called_once_with(
self.sys_pci_col._conn,
('/redfish/v1/Systems/1/PCIDevices/1'),
redfish_version=self.sys_pci_col.redfish_version)
self.sys_pci_col.redfish_version, None)
@mock.patch.object(pci_device, 'PCIDevice', autospec=True)
def test_get_members(self, mock_pci):
@ -78,9 +79,9 @@ class PCIDeviceCollectionTestCase(testtools.TestCase):
"/redfish/v1/Systems/1/PCIDevices/6"]
calls = [
mock.call(self.sys_pci_col._conn, path_list[0],
redfish_version=self.sys_pci_col.redfish_version),
self.sys_pci_col.redfish_version, None),
mock.call(self.sys_pci_col._conn, path_list[1],
redfish_version=self.sys_pci_col.redfish_version)
self.sys_pci_col.redfish_version, None)
]
mock_pci.assert_has_calls(calls)
self.assertIsInstance(members, list)