How to use _param_helper method in tempest

Best Python code snippet using tempest_python

test_agents.py

Source:test_agents.py Github

copy

Full Screen

...24 super(AgentsAdminTestJSON, cls).setup_clients()25 cls.client = cls.os_adm.agents_client26 def setUp(self):27 super(AgentsAdminTestJSON, self).setUp()28 params = self._param_helper(29 hypervisor='common', os='linux', architecture='x86_64',30 version='7.0', url='xxx://xxxx/xxx/xxx',31 md5hash='add6bb58e139be103324d04d82d8f545')32 body = self.client.create_agent(**params)['agent']33 self.agent_id = body['agent_id']34 def tearDown(self):35 try:36 self.client.delete_agent(self.agent_id)37 except lib_exc.NotFound:38 pass39 except Exception:40 LOG.exception('Exception raised deleting agent %s', self.agent_id)41 super(AgentsAdminTestJSON, self).tearDown()42 def _param_helper(self, **kwargs):43 rand_key = 'architecture'44 if rand_key in kwargs:45 # NOTE: The rand_name is for avoiding agent conflicts.46 # If you try to create an agent with the same hypervisor,47 # os and architecture as an existing agent, Nova will return48 # an HTTPConflict or HTTPServerError.49 kwargs[rand_key] = data_utils.rand_name(kwargs[rand_key])50 return kwargs51 @test.idempotent_id('1fc6bdc8-0b6d-4cc7-9f30-9b04fabe5b90')52 def test_create_agent(self):53 # Create an agent.54 params = self._param_helper(55 hypervisor='kvm', os='win', architecture='x86',56 version='7.0', url='xxx://xxxx/xxx/xxx',57 md5hash='add6bb58e139be103324d04d82d8f545')58 body = self.client.create_agent(**params)['agent']59 self.addCleanup(self.client.delete_agent, body['agent_id'])60 for expected_item, value in params.items():61 self.assertEqual(value, body[expected_item])62 @test.idempotent_id('dc9ffd51-1c50-4f0e-a820-ae6d2a568a9e')63 def test_update_agent(self):64 # Update an agent.65 params = self._param_helper(66 version='8.0', url='xxx://xxxx/xxx/xxx2',67 md5hash='add6bb58e139be103324d04d82d8f547')68 body = self.client.update_agent(self.agent_id, **params)['agent']69 for expected_item, value in params.items():70 self.assertEqual(value, body[expected_item])71 @test.idempotent_id('470e0b89-386f-407b-91fd-819737d0b335')72 def test_delete_agent(self):73 # Delete an agent.74 self.client.delete_agent(self.agent_id)75 # Verify the list doesn't contain the deleted agent.76 agents = self.client.list_agents()['agents']77 self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))78 @test.idempotent_id('6a326c69-654b-438a-80a3-34bcc454e138')79 def test_list_agents(self):80 # List all agents.81 agents = self.client.list_agents()['agents']82 self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)83 self.assertIn(self.agent_id, map(lambda x: x['agent_id'], agents))84 @test.idempotent_id('eabadde4-3cd7-4ec4-a4b5-5a936d2d4408')85 def test_list_agents_with_filter(self):86 # List the agent builds by the filter.87 params = self._param_helper(88 hypervisor='xen', os='linux', architecture='x86',89 version='7.0', url='xxx://xxxx/xxx/xxx1',90 md5hash='add6bb58e139be103324d04d82d8f546')91 agent_xen = self.client.create_agent(**params)['agent']92 self.addCleanup(self.client.delete_agent, agent_xen['agent_id'])93 agent_id_xen = agent_xen['agent_id']94 agents = (self.client.list_agents(hypervisor=agent_xen['hypervisor'])95 ['agents'])96 self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)97 self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful