How to use _get_host_name method in tempest

Best Python code snippet using tempest_python

test_hosts_negative.py

Source:test_hosts_negative.py Github

copy

Full Screen

...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):...

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