Best Python code snippet using tempest_python
test_hosts_negative.py
Source: test_hosts_negative.py
...25 def setUpClass(cls):26 super(HostsAdminNegativeTestJSON, cls).setUpClass()27 cls.client = cls.os_adm.hosts_client28 cls.non_admin_client = cls.os.hosts_client29 def _get_host_name(self):30 resp, hosts = self.client.list_hosts()31 self.assertEqual(200, resp.status)32 self.assertTrue(len(hosts) >= 1)33 hostname = hosts[0]['host_name']34 return hostname35 @attr(type=['negative', 'gate'])36 def test_list_hosts_with_non_admin_user(self):37 self.assertRaises(exceptions.Unauthorized,38 self.non_admin_client.list_hosts)39 @attr(type=['negative', 'gate'])40 def test_show_host_detail_with_nonexistent_hostname(self):41 nonexitent_hostname = data_utils.rand_name('rand_hostname')42 self.assertRaises(exceptions.NotFound,43 self.client.show_host_detail, nonexitent_hostname)44 @attr(type=['negative', 'gate'])45 def test_show_host_detail_with_non_admin_user(self):46 hostname = self._get_host_name()47 self.assertRaises(exceptions.Unauthorized,48 self.non_admin_client.show_host_detail,49 hostname)50 @attr(type=['negative', 'gate'])51 def test_update_host_with_non_admin_user(self):52 hostname = self._get_host_name()53 self.assertRaises(exceptions.Unauthorized,54 self.non_admin_client.update_host,55 hostname)56 @attr(type=['negative', 'gate'])57 def test_update_host_with_extra_param(self):58 # only 'status' and 'maintenance_mode' are the valid params.59 hostname = self._get_host_name()60 self.assertRaises(exceptions.BadRequest,61 self.client.update_host,62 hostname,63 status='enable',64 maintenance_mode='enable',65 param='XXX')66 @attr(type=['negative', 'gate'])67 def test_update_host_with_invalid_status(self):68 # 'status' can only be 'enable' or 'disable'69 hostname = self._get_host_name()70 self.assertRaises(exceptions.BadRequest,71 self.client.update_host,72 hostname,73 status='invalid',74 maintenance_mode='enable')75 @attr(type=['negative', 'gate'])76 def test_update_host_with_invalid_maintenance_mode(self):77 # 'maintenance_mode' can only be 'enable' or 'disable'78 hostname = self._get_host_name()79 self.assertRaises(exceptions.BadRequest,80 self.client.update_host,81 hostname,82 status='enable',83 maintenance_mode='invalid')84 @attr(type=['negative', 'gate'])85 def test_update_host_without_param(self):86 # 'status' or 'maintenance_mode' needed for host update87 hostname = self._get_host_name()88 self.assertRaises(exceptions.BadRequest,89 self.client.update_host,90 hostname)91 @attr(type=['negative', 'gate'])92 def test_update_nonexistent_host(self):93 nonexitent_hostname = data_utils.rand_name('rand_hostname')94 self.assertRaises(exceptions.NotFound,95 self.client.update_host,96 nonexitent_hostname,97 status='enable',98 maintenance_mode='enable')99 @attr(type=['negative', 'gate'])100 def test_startup_nonexistent_host(self):101 nonexitent_hostname = data_utils.rand_name('rand_hostname')102 self.assertRaises(exceptions.NotFound,103 self.client.startup_host,104 nonexitent_hostname)105 @attr(type=['negative', 'gate'])106 def test_startup_host_with_non_admin_user(self):107 hostname = self._get_host_name()108 self.assertRaises(exceptions.Unauthorized,109 self.non_admin_client.startup_host,110 hostname)111 @attr(type=['negative', 'gate'])112 def test_shutdown_nonexistent_host(self):113 nonexitent_hostname = data_utils.rand_name('rand_hostname')114 self.assertRaises(exceptions.NotFound,115 self.client.shutdown_host,116 nonexitent_hostname)117 @attr(type=['negative', 'gate'])118 def test_shutdown_host_with_non_admin_user(self):119 hostname = self._get_host_name()120 self.assertRaises(exceptions.Unauthorized,121 self.non_admin_client.shutdown_host,122 hostname)123 @attr(type=['negative', 'gate'])124 def test_reboot_nonexistent_host(self):125 nonexitent_hostname = data_utils.rand_name('rand_hostname')126 self.assertRaises(exceptions.NotFound,127 self.client.reboot_host,128 nonexitent_hostname)129 @attr(type=['negative', 'gate'])130 def test_reboot_host_with_non_admin_user(self):131 hostname = self._get_host_name()132 self.assertRaises(exceptions.Unauthorized,133 self.non_admin_client.reboot_host,134 hostname)135class HostsAdminNegativeTestXML(HostsAdminNegativeTestJSON):...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!