Best Python code snippet using tempest_python
test_hypervisor.py
Source:test_hypervisor.py
...25 def setUpClass(cls):26 super(HypervisorAdminTestJSON, cls).setUpClass()27 cls.client = cls.os_adm.hypervisor_client28 cls.non_adm_client = cls.hypervisor_client29 def _list_hypervisors(self):30 # List of hypervisors31 resp, hypers = self.client.get_hypervisor_list()32 self.assertEqual(200, resp.status)33 return hypers34 @attr(type='gate')35 def test_get_hypervisor_list(self):36 # List of hypervisor and available hypervisors hostname37 hypers = self._list_hypervisors()38 self.assertTrue(len(hypers) > 0)39 @attr(type='gate')40 def test_get_hypervisor_list_details(self):41 # Display the details of the all hypervisor42 resp, hypers = self.client.get_hypervisor_list_details()43 self.assertEqual(200, resp.status)44 self.assertTrue(len(hypers) > 0)45 @attr(type='gate')46 def test_get_hypervisor_show_details(self):47 # Display the details of the specified hypervisor48 hypers = self._list_hypervisors()49 self.assertTrue(len(hypers) > 0)50 resp, details = (self.client.51 get_hypervisor_show_details(hypers[0]['id']))52 self.assertEqual(200, resp.status)53 self.assertTrue(len(details) > 0)54 self.assertEqual(details['hypervisor_hostname'],55 hypers[0]['hypervisor_hostname'])56 @attr(type='gate')57 def test_get_hypervisor_show_servers(self):58 # Show instances about the specific hypervisors59 hypers = self._list_hypervisors()60 self.assertTrue(len(hypers) > 0)61 hostname = hypers[0]['hypervisor_hostname']62 resp, hypervisors = self.client.get_hypervisor_servers(hostname)63 self.assertEqual(200, resp.status)64 self.assertTrue(len(hypervisors) > 0)65 @attr(type='gate')66 def test_get_hypervisor_stats(self):67 # Verify the stats of the all hypervisor68 resp, stats = self.client.get_hypervisor_stats()69 self.assertEqual(200, resp.status)70 self.assertTrue(len(stats) > 0)71 @attr(type='gate')72 def test_get_hypervisor_uptime(self):73 # Verify that GET shows the specified hypervisor uptime74 hypers = self._list_hypervisors()75 resp, uptime = self.client.get_hypervisor_uptime(hypers[0]['id'])76 self.assertEqual(200, resp.status)77 self.assertTrue(len(uptime) > 0)78 @attr(type=['negative', 'gate'])79 def test_get_hypervisor_list_with_non_admin_user(self):80 # List of hypervisor and available services with non admin user81 self.assertRaises(82 exceptions.Unauthorized,83 self.non_adm_client.get_hypervisor_list)84 @attr(type=['negative', 'gate'])85 def test_get_hypervisor_list_details_with_non_admin_user(self):86 # List of hypervisor details and available services with non admin user87 self.assertRaises(88 exceptions.Unauthorized,...
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!!