Merge "Deduplicate _assertExpected method in tests"
This commit is contained in:
commit
36315765af
@ -118,6 +118,13 @@ class BaseBaremetalTest(api_version_utils.BaseMicroversionTest,
|
|||||||
finally:
|
finally:
|
||||||
super(BaseBaremetalTest, cls).resource_cleanup()
|
super(BaseBaremetalTest, cls).resource_cleanup()
|
||||||
|
|
||||||
|
def _assertExpected(self, expected, actual):
|
||||||
|
"""Check if not expected keys/values exist in actual response body."""
|
||||||
|
for key, value in expected.items():
|
||||||
|
if key not in ('created_at', 'updated_at'):
|
||||||
|
self.assertIn(key, actual)
|
||||||
|
self.assertEqual(value, actual[key])
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseBaremetalTest, self).setUp()
|
super(BaseBaremetalTest, self).setUp()
|
||||||
self.useFixture(api_microversion_fixture.APIMicroversionFixture(
|
self.useFixture(api_microversion_fixture.APIMicroversionFixture(
|
||||||
|
@ -26,13 +26,6 @@ class TestChassis(base.BaseBaremetalTest):
|
|||||||
super(TestChassis, cls).resource_setup()
|
super(TestChassis, cls).resource_setup()
|
||||||
_, cls.chassis = cls.create_chassis()
|
_, cls.chassis = cls.create_chassis()
|
||||||
|
|
||||||
def _assertExpected(self, expected, actual):
|
|
||||||
# Check if not expected keys/values exists in actual response body
|
|
||||||
for key, value in expected.items():
|
|
||||||
if key not in ('created_at', 'updated_at'):
|
|
||||||
self.assertIn(key, actual)
|
|
||||||
self.assertEqual(value, actual[key])
|
|
||||||
|
|
||||||
@decorators.idempotent_id('7c5a2e09-699c-44be-89ed-2bc189992d42')
|
@decorators.idempotent_id('7c5a2e09-699c-44be-89ed-2bc189992d42')
|
||||||
def test_create_chassis(self):
|
def test_create_chassis(self):
|
||||||
descr = data_utils.rand_name('test-chassis')
|
descr = data_utils.rand_name('test-chassis')
|
||||||
|
@ -29,13 +29,6 @@ class TestNodes(base.BaseBaremetalTest):
|
|||||||
_, self.chassis = self.create_chassis()
|
_, self.chassis = self.create_chassis()
|
||||||
_, self.node = self.create_node(self.chassis['uuid'])
|
_, self.node = self.create_node(self.chassis['uuid'])
|
||||||
|
|
||||||
def _assertExpected(self, expected, actual):
|
|
||||||
# Check if not expected keys/values exists in actual response body
|
|
||||||
for key, value in expected.items():
|
|
||||||
if key not in ('created_at', 'updated_at'):
|
|
||||||
self.assertIn(key, actual)
|
|
||||||
self.assertEqual(value, actual[key])
|
|
||||||
|
|
||||||
def _associate_node_with_instance(self):
|
def _associate_node_with_instance(self):
|
||||||
self.client.set_node_power_state(self.node['uuid'], 'power off')
|
self.client.set_node_power_state(self.node['uuid'], 'power off')
|
||||||
waiters.wait_for_bm_node_status(self.client, self.node['uuid'],
|
waiters.wait_for_bm_node_status(self.client, self.node['uuid'],
|
||||||
|
@ -28,13 +28,6 @@ class TestPorts(base.BaseBaremetalTest):
|
|||||||
_, self.port = self.create_port(self.node['uuid'],
|
_, self.port = self.create_port(self.node['uuid'],
|
||||||
data_utils.rand_mac_address())
|
data_utils.rand_mac_address())
|
||||||
|
|
||||||
def _assertExpected(self, expected, actual):
|
|
||||||
# Check if not expected keys/values exists in actual response body
|
|
||||||
for key, value in expected.items():
|
|
||||||
if key not in ('created_at', 'updated_at'):
|
|
||||||
self.assertIn(key, actual)
|
|
||||||
self.assertEqual(value, actual[key])
|
|
||||||
|
|
||||||
@decorators.idempotent_id('83975898-2e50-42ed-b5f0-e510e36a0b56')
|
@decorators.idempotent_id('83975898-2e50-42ed-b5f0-e510e36a0b56')
|
||||||
def test_create_port(self):
|
def test_create_port(self):
|
||||||
node_id = self.node['uuid']
|
node_id = self.node['uuid']
|
||||||
|
Loading…
Reference in New Issue
Block a user