Browse Source

Merge "Update test cases for test_bay.py and test_baymodel.py"

changes/30/209730/1
Jenkins 7 years ago committed by Gerrit Code Review
parent
commit
3feb5aefb5
  1. 42
      magnum/tests/unit/api/controllers/v1/test_bay.py
  2. 26
      magnum/tests/unit/api/controllers/v1/test_baymodel.py

42
magnum/tests/unit/api/controllers/v1/test_bay.py

@ -52,34 +52,24 @@ class TestListBay(api_base.FunctionalTest):
bay = obj_utils.create_test_bay(self.context)
response = self.get_json('/bays')
self.assertEqual(bay.uuid, response['bays'][0]["uuid"])
self.assertIn('name', response['bays'][0])
self.assertIn('baymodel_id', response['bays'][0])
self.assertIn('node_count', response['bays'][0])
self.assertIn('status', response['bays'][0])
for key in ("name", "baymodel_id", "node_count", "status"):
self.assertIn(key, response['bays'][0])
def test_get_one(self):
bay = obj_utils.create_test_bay(self.context)
response = self.get_json('/bays/%s' % bay['uuid'])
self.assertEqual(bay.uuid, response['uuid'])
self.assertIn('name', response)
self.assertIn('baymodel_id', response)
self.assertIn('node_count', response)
self.assertIn('status', response)
self.assertIn('discovery_url', response)
self.assertIn('api_address', response)
self.assertIn('node_addresses', response)
for key in ("name", "baymodel_id", "node_count", "status",
"api_address", "discovery_url", "node_addresses"):
self.assertIn(key, response)
def test_get_one_by_name(self):
bay = obj_utils.create_test_bay(self.context)
response = self.get_json('/bays/%s' % bay['name'])
self.assertEqual(bay.uuid, response['uuid'])
self.assertIn('name', response)
self.assertIn('baymodel_id', response)
self.assertIn('node_count', response)
self.assertIn('status', response)
self.assertIn('discovery_url', response)
self.assertIn('api_address', response)
self.assertIn('node_addresses', response)
for key in ("name", "baymodel_id", "node_count", "status",
"api_address", "discovery_url", "node_addresses"):
self.assertIn(key, response)
def test_get_one_by_name_not_found(self):
response = self.get_json(
@ -115,10 +105,8 @@ class TestListBay(api_base.FunctionalTest):
bay = obj_utils.create_test_bay(self.context)
response = self.get_json('/bays/detail')
self.assertEqual(bay.uuid, response['bays'][0]["uuid"])
self.assertIn('name', response['bays'][0])
self.assertIn('baymodel_id', response['bays'][0])
self.assertIn('node_count', response['bays'][0])
self.assertIn('status', response['bays'][0])
for key in ("name", "baymodel_id", "node_count", "status"):
self.assertIn(key, response['bays'][0])
def test_detail_with_pagination_marker(self):
bay_list = []
@ -131,13 +119,9 @@ class TestListBay(api_base.FunctionalTest):
% bay_list[2].uuid)
self.assertEqual(1, len(response['bays']))
self.assertEqual(bay_list[-1].uuid, response['bays'][0]['uuid'])
self.assertIn('name', response['bays'][0])
self.assertIn('baymodel_id', response['bays'][0])
self.assertIn('node_count', response['bays'][0])
self.assertIn('status', response['bays'][0])
self.assertIn('discovery_url', response['bays'][0])
self.assertIn('api_address', response['bays'][0])
self.assertIn('node_addresses', response['bays'][0])
for key in ("name", "baymodel_id", "node_count", "status",
"discovery_url", "api_address", "node_addresses"):
self.assertIn(key, response['bays'][0])
def test_detail_against_single(self):
bay = obj_utils.create_test_bay(self.context)

26
magnum/tests/unit/api/controllers/v1/test_baymodel.py

@ -123,15 +123,10 @@ class TestListBayModel(api_base.FunctionalTest):
baymodel = obj_utils.create_test_baymodel(self.context)
response = self.get_json('/baymodels/detail')
self.assertEqual(baymodel.uuid, response['baymodels'][0]["uuid"])
self.assertIn('flavor_id', response['baymodels'][0])
self.assertIn('master_flavor_id', response['baymodels'][0])
self.assertIn('dns_nameserver', response['baymodels'][0])
self.assertIn('keypair_id', response['baymodels'][0])
self.assertIn('external_network_id', response['baymodels'][0])
self.assertIn('fixed_network', response['baymodels'][0])
self.assertIn('docker_volume_size', response['baymodels'][0])
self.assertIn('ssh_authorized_key', response['baymodels'][0])
self.assertIn('coe', response['baymodels'][0])
for key in ("flavor_id", "master_flavor_id", "dns_nameserver",
"keypair_id", "external_network_id", "fixed_network",
"docker_volume_size", "ssh_authorized_key", "coe"):
self.assertIn(key, response['baymodels'][0])
def test_detail_with_pagination_marker(self):
bm_list = []
@ -145,15 +140,10 @@ class TestListBayModel(api_base.FunctionalTest):
% bm_list[2].uuid)
self.assertEqual(1, len(response['baymodels']))
self.assertEqual(bm_list[-1].uuid, response['baymodels'][0]['uuid'])
self.assertIn('flavor_id', response['baymodels'][0])
self.assertIn('master_flavor_id', response['baymodels'][0])
self.assertIn('dns_nameserver', response['baymodels'][0])
self.assertIn('keypair_id', response['baymodels'][0])
self.assertIn('external_network_id', response['baymodels'][0])
self.assertIn('fixed_network', response['baymodels'][0])
self.assertIn('docker_volume_size', response['baymodels'][0])
self.assertIn('ssh_authorized_key', response['baymodels'][0])
self.assertIn('coe', response['baymodels'][0])
for key in ("flavor_id", "master_flavor_id", "dns_nameserver",
"keypair_id", "external_network_id", "fixed_network",
"docker_volume_size", "ssh_authorized_key", "coe"):
self.assertIn(key, response['baymodels'][0])
def test_detail_against_single(self):
baymodel = obj_utils.create_test_baymodel(self.context)

Loading…
Cancel
Save