Merge "Deduplicate _assertExpected method in tests"

This commit is contained in:
Jenkins 2017-02-22 06:07:15 +00:00 committed by Gerrit Code Review
commit 36315765af
4 changed files with 7 additions and 21 deletions

View File

@ -118,6 +118,13 @@ class BaseBaremetalTest(api_version_utils.BaseMicroversionTest,
finally:
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):
super(BaseBaremetalTest, self).setUp()
self.useFixture(api_microversion_fixture.APIMicroversionFixture(

View File

@ -26,13 +26,6 @@ class TestChassis(base.BaseBaremetalTest):
super(TestChassis, cls).resource_setup()
_, 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')
def test_create_chassis(self):
descr = data_utils.rand_name('test-chassis')

View File

@ -29,13 +29,6 @@ class TestNodes(base.BaseBaremetalTest):
_, self.chassis = self.create_chassis()
_, 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):
self.client.set_node_power_state(self.node['uuid'], 'power off')
waiters.wait_for_bm_node_status(self.client, self.node['uuid'],

View File

@ -28,13 +28,6 @@ class TestPorts(base.BaseBaremetalTest):
_, self.port = self.create_port(self.node['uuid'],
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')
def test_create_port(self):
node_id = self.node['uuid']