Best Python code snippet using tempest_python
test_agents.py
Source: test_agents.py
...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))...
Check out the latest blogs from LambdaTest on this topic:
Companies are using DevOps to quickly respond to changing market dynamics and customer requirements.
Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
The best agile teams are built from people who work together as one unit, where each team member has both the technical and the personal skills to allow the team to become self-organized, cross-functional, and self-motivated. These are all big words that I hear in almost every agile project. Still, the criteria to make a fantastic agile team are practically impossible to achieve without one major factor: motivation towards a common goal.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!