Do not print empty list in assertNotEmpty
1. Printing empty list in assertNotEmpty is meaningless 2. Do not use one line function especially when that line is not very long. Change-Id: If952fd622cad9528cbb0532d8d7f573e97869342
This commit is contained in:
@@ -86,7 +86,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
body = self.client.create_agent(**self.params_agent)['agent']
|
body = self.client.create_agent(**self.params_agent)['agent']
|
||||||
self.addCleanup(self.client.delete_agent, body['agent_id'])
|
self.addCleanup(self.client.delete_agent, body['agent_id'])
|
||||||
agents = self.client.list_agents()['agents']
|
agents = self.client.list_agents()['agents']
|
||||||
self.assertNotEmpty(agents, 'Cannot get any agents.(%s)' % agents)
|
self.assertNotEmpty(agents, 'Cannot get any agents.')
|
||||||
self.assertIn(body['agent_id'], map(lambda x: x['agent_id'], agents))
|
self.assertIn(body['agent_id'], map(lambda x: x['agent_id'], agents))
|
||||||
|
|
||||||
@decorators.idempotent_id('eabadde4-3cd7-4ec4-a4b5-5a936d2d4408')
|
@decorators.idempotent_id('eabadde4-3cd7-4ec4-a4b5-5a936d2d4408')
|
||||||
@@ -104,7 +104,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
agent_id_xen = agent_xen['agent_id']
|
agent_id_xen = agent_xen['agent_id']
|
||||||
agents = (self.client.list_agents(hypervisor=agent_xen['hypervisor'])
|
agents = (self.client.list_agents(hypervisor=agent_xen['hypervisor'])
|
||||||
['agents'])
|
['agents'])
|
||||||
self.assertNotEmpty(agents, 'Cannot get any agents.(%s)' % agents)
|
self.assertNotEmpty(agents, 'Cannot get any agents.')
|
||||||
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
|
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
|
||||||
self.assertNotIn(body['agent_id'], map(lambda x: x['agent_id'],
|
self.assertNotIn(body['agent_id'], map(lambda x: x['agent_id'],
|
||||||
agents))
|
agents))
|
||||||
|
|||||||
@@ -30,26 +30,23 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
hypers = self.client.list_hypervisors()['hypervisors']
|
hypers = self.client.list_hypervisors()['hypervisors']
|
||||||
return hypers
|
return hypers
|
||||||
|
|
||||||
def assertHypervisors(self, hypers):
|
|
||||||
self.assertNotEmpty(hypers, "No hypervisors found: %s" % hypers)
|
|
||||||
|
|
||||||
@decorators.idempotent_id('7f0ceacd-c64d-4e96-b8ee-d02943142cc5')
|
@decorators.idempotent_id('7f0ceacd-c64d-4e96-b8ee-d02943142cc5')
|
||||||
def test_get_hypervisor_list(self):
|
def test_get_hypervisor_list(self):
|
||||||
# List of hypervisor and available hypervisors hostname
|
# List of hypervisor and available hypervisors hostname
|
||||||
hypers = self._list_hypervisors()
|
hypers = self._list_hypervisors()
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
|
|
||||||
@decorators.idempotent_id('1e7fdac2-b672-4ad1-97a4-bad0e3030118')
|
@decorators.idempotent_id('1e7fdac2-b672-4ad1-97a4-bad0e3030118')
|
||||||
def test_get_hypervisor_list_details(self):
|
def test_get_hypervisor_list_details(self):
|
||||||
# Display the details of the all hypervisor
|
# Display the details of the all hypervisor
|
||||||
hypers = self.client.list_hypervisors(detail=True)['hypervisors']
|
hypers = self.client.list_hypervisors(detail=True)['hypervisors']
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
|
|
||||||
@decorators.idempotent_id('94ff9eae-a183-428e-9cdb-79fde71211cc')
|
@decorators.idempotent_id('94ff9eae-a183-428e-9cdb-79fde71211cc')
|
||||||
def test_get_hypervisor_show_details(self):
|
def test_get_hypervisor_show_details(self):
|
||||||
# Display the details of the specified hypervisor
|
# Display the details of the specified hypervisor
|
||||||
hypers = self._list_hypervisors()
|
hypers = self._list_hypervisors()
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
|
|
||||||
details = self.client.show_hypervisor(hypers[0]['id'])['hypervisor']
|
details = self.client.show_hypervisor(hypers[0]['id'])['hypervisor']
|
||||||
self.assertNotEmpty(details)
|
self.assertNotEmpty(details)
|
||||||
@@ -60,7 +57,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
def test_get_hypervisor_show_servers(self):
|
def test_get_hypervisor_show_servers(self):
|
||||||
# Show instances about the specific hypervisors
|
# Show instances about the specific hypervisors
|
||||||
hypers = self._list_hypervisors()
|
hypers = self._list_hypervisors()
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
|
|
||||||
hostname = hypers[0]['hypervisor_hostname']
|
hostname = hypers[0]['hypervisor_hostname']
|
||||||
hypervisors = (self.client.list_servers_on_hypervisor(hostname)
|
hypervisors = (self.client.list_servers_on_hypervisor(hostname)
|
||||||
@@ -116,7 +113,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
@decorators.idempotent_id('d7e1805b-3b14-4a3b-b6fd-50ec6d9f361f')
|
@decorators.idempotent_id('d7e1805b-3b14-4a3b-b6fd-50ec6d9f361f')
|
||||||
def test_search_hypervisor(self):
|
def test_search_hypervisor(self):
|
||||||
hypers = self._list_hypervisors()
|
hypers = self._list_hypervisors()
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
hypers = self.client.search_hypervisor(
|
hypers = self.client.search_hypervisor(
|
||||||
hypers[0]['hypervisor_hostname'])['hypervisors']
|
hypers[0]['hypervisor_hostname'])['hypervisors']
|
||||||
self.assertHypervisors(hypers)
|
self.assertNotEmpty(hypers, "No hypervisors found.")
|
||||||
|
|||||||
Reference in New Issue
Block a user