Best Python code snippet using tempest_python
test_servers_client.py
Source:test_servers_client.py  
...610            {},611            status=202,612            server_id=self.server_id613            )614    def test_pause_server(self):615        self.check_service_client_function(616            self.client.pause_server,617            'tempest.lib.common.rest_client.RestClient.post',618            {},619            status=202,620            server_id=self.server_id621            )622    def test_unpause_server(self):623        self.check_service_client_function(624            self.client.unpause_server,625            'tempest.lib.common.rest_client.RestClient.post',626            {},627            status=202,628            server_id=self.server_id...test_server_actions_rbac.py
Source:test_server_actions_rbac.py  
...106                          'Pause is not available.')107    @rbac_rule_validation.action(108        service="nova",109        rules=["os_compute_api:os-pause-server:pause"])110    def test_pause_server(self):111        with self.override_role():112            self._pause_server()113    @decorators.idempotent_id('087008cf-82fa-4eeb-ae8b-32c4126456ad')114    @testtools.skipUnless(CONF.compute_feature_enabled.pause,115                          'Pause is not available.')116    @rbac_rule_validation.action(117        service="nova",118        rules=["os_compute_api:os-pause-server:unpause"])119    def test_unpause_server(self):120        self._pause_server()121        with self.override_role():122            self.servers_client.unpause_server(self.server_id)123        waiters.wait_for_server_status(124            self.servers_client, self.server_id, 'ACTIVE')...generate_example_data.py
Source:generate_example_data.py  
1import random2import time3files = [4    'network/linux_net.py',5    'test.py',6    'tests/unit/api/openstack/compute/admin_only_action_common.py',7    'tests/unit/api/openstack/compute/test_admin_actions.py',8    'tests/unit/api/openstack/compute/test_block_device_mapping.py',9    'tests/unit/api/openstack/compute/test_lock_server.py',10    'tests/unit/api/openstack/compute/test_migrate_server.py',11    'tests/unit/api/openstack/compute/test_migrations.py',12    'tests/unit/api/openstack/compute/test_pause_server.py',13    'tests/unit/api/openstack/compute/test_quotas.py',14    'tests/unit/api/openstack/compute/test_suspend_server.py',15    'tests/unit/api/openstack/compute/test_virtual_interfaces.py',16    'tests/unit/api/openstack/compute/test_volumes.py',17    'tests/unit/cells/fakes.py',18    'tests/unit/cells/test_cells_manager.py',19    'tests/unit/cells/test_cells_messaging.py',20    'tests/unit/cells/test_cells_rpc_driver.py',21    'tests/unit/compute/test_compute_api.py',22    'tests/unit/conductor/tasks/test_live_migrate.py',23    'tests/unit/conductor/test_conductor.py',24    'tests/unit/consoleauth/test_consoleauth.py',25    'tests/unit/network/test_linux_net.py',26    'tests/unit/network/test_manager.py',27    'tests/unit/network/test_neutronv2.py',28    'tests/unit/objects/test_instance.py',29    'tests/unit/test_service.py',30    'tests/unit/virt/libvirt/test_driver.py',31    'tests/unit/virt/test_block_device.py',32    'tests/unit/virt/test_virt_drivers.py',33    'tests/unit/virt/vmwareapi/test_driver_api.py',34    'tests/unit/virt/xenapi/image/test_utils.py',35    'tests/unit/virt/xenapi/image/test_vdi_through_dev.py',36    'tests/unit/virt/xenapi/test_vm_utils.py',37    'tests/unit/virt/xenapi/test_vmops.py',38    'tests/unit/virt/xenapi/test_xenapi.py',39]40with open('data/num_matched_files.csv', 'w') as f:41    ts = int(time.time())42    hr = 60*6043    records = 10044    c = ''45    for i in range(0, records):46        cts = ts-((records-i)*hr)47        val = len(files)-int((i/(float(records))*len(files)))48        c += '{0},{1}'.format(cts, val) + '\n'49    f.write(c)50with open('data/num_matched_lines.csv', 'w') as f:51    ts = int(time.time())52    hr = 60*6053    records = 100054    todo = 180055    c = ''56    for i in range(0, records):57        cts = ts-((records-i)*hr)58        done = random.randint(0, int(todo/float(100)))59        todo -= done60        c += '{0},{1}'.format(cts, todo) + '\n'...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!!
