Apply a naming rule of GET to compute clients(n*)
[GET /resources] methods should be "list_<resource name>s" or "show_<resource name>", so this patch applies the rule to compute clients which name is "networks". In addition, this patch moves "name" filter of list_networks to caller side because this filter is used at one place. Partially implements blueprint consistent-service-method-names Change-Id: Ic2f7b8a2724035f0b2cd9def13cd7f7fc1e9924d
This commit is contained in:
parent
a89dd6bcd0
commit
46f574e74e
|
@ -47,7 +47,7 @@ class NetworksTest(base.BaseComputeAdminTest):
|
|||
else:
|
||||
configured_network = networks
|
||||
configured_network = configured_network[0]
|
||||
network = self.client.get_network(configured_network['id'])
|
||||
network = self.client.show_network(configured_network['id'])
|
||||
self.assertEqual(configured_network['label'], network['label'])
|
||||
|
||||
@test.idempotent_id('df3d1046-6fa5-4b2c-ad0c-cfa46a351cb9')
|
||||
|
|
|
@ -40,7 +40,8 @@ def get_network_from_name(name, compute_networks_client):
|
|||
if not name:
|
||||
raise exceptions.InvalidConfiguration()
|
||||
|
||||
networks = compute_networks_client.list_networks(name=name)
|
||||
networks = compute_networks_client.list_networks()
|
||||
networks = [n for n in networks if n['label'] == name]
|
||||
|
||||
# Check that a network exists, else raise an InvalidConfigurationException
|
||||
if len(networks) == 1:
|
||||
|
|
|
@ -20,17 +20,13 @@ from tempest.common import service_client
|
|||
|
||||
class NetworksClientJSON(service_client.ServiceClient):
|
||||
|
||||
def list_networks(self, name=None):
|
||||
def list_networks(self):
|
||||
resp, body = self.get("os-networks")
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
if name:
|
||||
networks = [n for n in body['networks'] if n['label'] == name]
|
||||
else:
|
||||
networks = body['networks']
|
||||
return service_client.ResponseBodyList(resp, networks)
|
||||
return service_client.ResponseBodyList(resp, body['networks'])
|
||||
|
||||
def get_network(self, network_id):
|
||||
def show_network(self, network_id):
|
||||
resp, body = self.get("os-networks/%s" % str(network_id))
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
|
|
|
@ -299,7 +299,8 @@ class TestAccount(base.TestCase):
|
|||
test_accounts_class = accounts.Accounts('v2', 'test_name')
|
||||
with mock.patch('tempest.services.compute.json.networks_client.'
|
||||
'NetworksClientJSON.list_networks',
|
||||
return_value=[{'name': 'network-2', 'id': 'fake-id'}]):
|
||||
return_value=[{'name': 'network-2', 'id': 'fake-id',
|
||||
'label': 'network-2'}]):
|
||||
creds = test_accounts_class.get_creds_by_roles(['role-7'])
|
||||
self.assertTrue(isinstance(creds, cred_provider.TestResources))
|
||||
network = creds.network
|
||||
|
|
Loading…
Reference in New Issue