Browse Source

Fix order of arguments in assertEqual

Some tests used incorrect order assertEqual(observed, expected).
The correct order expected by testtools is
assertEqual(expected, observed).
This patch fix the issue in the module magnum/tests/functional/.

Change-Id: Ic5151d6052780180179189cf47cc41f9215e2af5
Partial-Bug: #1259292
changes/32/233332/1
lei-zhang-99cloud 7 years ago
parent
commit
cfec863458
  1. 18
      magnum/tests/functional/api/v1/test_baymodel.py
  2. 2
      magnum/tests/functional/common/utils.py
  3. 16
      magnum/tests/functional/test_k8s_python_client.py

18
magnum/tests/functional/api/v1/test_baymodel.py

@ -39,14 +39,14 @@ class BayModelTest(base.BaseMagnumTest):
def _create_baymodel(self, baymodel_model, user='default'):
resp, model = cli.BayModelClient.as_user(user).post_baymodel(
baymodel_model)
self.assertEqual(resp.status, 201)
self.assertEqual(201, resp.status)
self.baymodels.append((model.uuid, user))
return resp, model
def _delete_baymodel(self, baymodel_id, user='default'):
resp, model = cli.BayModelClient.as_user(user).delete_baymodel(
baymodel_id)
self.assertEqual(resp.status, 204)
self.assertEqual(204, resp.status)
return resp, model
@testtools.testcase.attr('positive')
@ -54,7 +54,7 @@ class BayModelTest(base.BaseMagnumTest):
gen_model = datagen.random_baymodel_data_w_valid_keypair_and_image_id()
_, temp_model = self._create_baymodel(gen_model, user='default')
resp, model = cli.BayModelClient.as_user('default').list_baymodels()
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertGreater(len(model.baymodels), 0)
self.assertIn(
temp_model.uuid, list([x['uuid'] for x in model.baymodels]))
@ -73,13 +73,13 @@ class BayModelTest(base.BaseMagnumTest):
bay_model_client = cli.BayModelClient.as_user('default')
resp, new_model = bay_model_client.patch_baymodel(
old_model.uuid, patch_model)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, model = cli.BayModelClient.as_user('default').get_baymodel(
new_model.uuid)
self.assertEqual(resp.status, 200)
self.assertEqual(new_model.uuid, old_model.uuid)
self.assertEqual(new_model.name, model.name)
self.assertEqual(200, resp.status)
self.assertEqual(old_model.uuid, new_model.uuid)
self.assertEqual(model.name, new_model.name)
@testtools.testcase.attr('positive')
def test_delete_baymodel_by_uuid(self):
@ -87,7 +87,7 @@ class BayModelTest(base.BaseMagnumTest):
resp, model = self._create_baymodel(gen_model, user='default')
resp, _ = cli.BayModelClient.as_user('default').delete_baymodel(
model.uuid)
self.assertEqual(resp.status, 204)
self.assertEqual(204, resp.status)
self.baymodels.remove((model.uuid, 'default'))
@testtools.testcase.attr('positive')
@ -96,7 +96,7 @@ class BayModelTest(base.BaseMagnumTest):
resp, model = self._create_baymodel(gen_model, user='default')
resp, _ = cli.BayModelClient.as_user('default').delete_baymodel(
model.name)
self.assertEqual(resp.status, 204)
self.assertEqual(204, resp.status)
self.baymodels.remove((model.uuid, 'default'))
@testtools.testcase.attr('negative')

2
magnum/tests/functional/common/utils.py

@ -67,7 +67,7 @@ def parameterized(data):
'one': dict(val=1),
})
def test_val(self, val):
self.assertEqual(self.get_val(), val)
self.assertEqual(val, self.get_val())
The above will generate two test cases:
`test_val_zero` which runs with val=0

16
magnum/tests/functional/test_k8s_python_client.py

@ -63,12 +63,12 @@ class TestKubernetesAPIs(BaseMagnumClient):
resp = self.k8s_api.create_namespaced_pod(body=pod_manifest,
namespace='default')
self.assertEqual(resp.metadata.name, 'test')
self.assertEqual('test', resp.metadata.name)
self.assertTrue(resp.status.phase)
resp = self.k8s_api.read_namespaced_pod(name='test',
namespace='default')
self.assertEqual(resp.metadata.name, 'test')
self.assertEqual('test', resp.metadata.name)
self.assertTrue(resp.status.phase)
resp = self.k8s_api.delete_namespaced_pod(name='test', body={},
@ -87,12 +87,12 @@ class TestKubernetesAPIs(BaseMagnumClient):
resp = self.k8s_api.create_namespaced_service(body=service_manifest,
namespace='default')
self.assertEqual(resp.metadata.name, 'frontend')
self.assertEqual('frontend', resp.metadata.name)
self.assertTrue(resp.status)
resp = self.k8s_api.read_namespaced_service(name='frontend',
namespace='default')
self.assertEqual(resp.metadata.name, 'frontend')
self.assertEqual('frontend', resp.metadata.name)
self.assertTrue(resp.status)
resp = self.k8s_api.delete_namespaced_service(name='frontend',
@ -116,13 +116,13 @@ class TestKubernetesAPIs(BaseMagnumClient):
resp = self.k8s_api.create_namespaced_replication_controller(
body=rc_manifest, namespace='default')
self.assertEqual(resp.metadata.name, 'frontend')
self.assertEqual(resp.spec.replicas, 2)
self.assertEqual('frontend', resp.metadata.name)
self.assertEqual(2, resp.spec.replicas)
resp = self.k8s_api.read_namespaced_replication_controller(
name='frontend', namespace='default')
self.assertEqual(resp.metadata.name, 'frontend')
self.assertEqual(resp.spec.replicas, 2)
self.assertEqual('frontend', resp.metadata.name)
self.assertEqual(2, resp.spec.replicas)
resp = self.k8s_api.delete_namespaced_replication_controller(
name='frontend', body={}, namespace='default')

Loading…
Cancel
Save