Best Python code snippet using tempest_python
test_aggregates.py
Source: test_aggregates.py
...350 self.req, "1", body={"add_host": "1"})351 def test_add_host_with_non_string(self):352 self.assertRaises(self.bad_request, eval(self.add_host),353 self.req, "1", body={"add_host": {"host": 1}})354 def test_remove_host(self):355 def stub_remove_host_from_aggregate(context, aggregate, host):356 self.assertEqual(context, self.context, "context")357 self.assertEqual("1", aggregate, "aggregate")358 self.assertEqual("host1", host, "host")359 stub_remove_host_from_aggregate.called = True360 return {}361 self.stubs.Set(self.controller.api,362 "remove_host_from_aggregate",363 stub_remove_host_from_aggregate)364 eval(self.remove_host)(self.req, "1",365 body={"remove_host": {"host": "host1"}})366 self.assertTrue(stub_remove_host_from_aggregate.called)367 def test_remove_host_no_admin(self):368 self.assertRaises(exception.PolicyNotAuthorized,...
test_sync_vm.py
Source: test_sync_vm.py
1import pytest2import json3class TestSyncVM:4 """5 Tests for sync vm6 """7 BAD_SYNC_VM_INPUT = [8 ('fake-backend-0-0', 'cannot resolve host'),9 ('backend-0-0', 'not a valid virtual machine'),10 ('hypervisor=backend-0-0', 'not a valid hypervisor')11 ]12 @pytest.mark.parametrize('params, msg', BAD_SYNC_VM_INPUT)13 def test_invalid_parameters(self, add_hypervisor, add_vm_multiple, add_host, host, params, msg):14 result = host.run(f'stack sync vm {params}')15 assert result.rc != 0 and msg in result.stderr16 def test_no_vm(self, add_host, host):17 result = host.run(f'stack sync vm')18 assert result.rc == 019 # Test VM's marked for deletion20 # aren't removed without using force21 def test_remove_after_sync(self, add_hypervisor, add_vm_multiple, host):22 remove_host = host.run(f'stack remove vm vm-backend-0-4')23 assert remove_host.rc == 024 sync_host = host.run('stack sync vm')25 assert sync_host.rc == 026 list_host = host.run('stack list vm hypervisor=hypervisor-0-1 output-format=json')27 assert list_host.rc == 028 assert json.loads(list_host.stdout) == [29 {30 'virtual machine': 'vm-backend-0-3',31 'hypervisor': 'hypervisor-0-1',32 'memory': 2048,33 'cpu': 1,34 'pending deletion': False35 },36 {37 'virtual machine': 'vm-backend-0-4',38 'hypervisor': 'hypervisor-0-1',39 'memory': 2048,40 'cpu': 2,41 'pending deletion': True42 }43 ]44 # Test with the force parameter45 # if VM's marked for deletion46 # are removed after running sync47 # even though the hypervisor48 # can't be reached49 def test_remove_after_sync_force(self, add_hypervisor, add_vm_multiple, host):50 remove_host = host.run(f'stack remove vm vm-backend-0-4')51 assert remove_host.rc == 052 sync_host = host.run('stack sync vm force=y')53 assert sync_host.rc == 054 list_host = host.run('stack list vm hypervisor=hypervisor-0-1 output-format=json')55 assert list_host.rc == 056 assert json.loads(list_host.stdout) == [{57 'virtual machine': 'vm-backend-0-3',58 'hypervisor': 'hypervisor-0-1',59 'memory': 2048,60 'cpu': 1,61 'pending deletion': False62 }]63 # Test syncing per hypervisor64 def test_sync_hypervisor(self, add_hypervisor, add_vm_multiple, host):65 # We mark two hosts for deletion but66 # only sync hypervisor-0-2, so only67 # vm-backend-0-6 should be removed68 remove_host = host.run(f'stack remove vm vm-backend-0-4')69 assert remove_host.rc == 070 remove_host = host.run(f'stack remove vm vm-backend-0-6')71 assert remove_host.rc == 072 # Since there is no live hypervisor73 # connection, force is needed here74 sync_host = host.run('stack sync vm hypervisor=hypervisor-0-2 force=y')75 assert sync_host.rc == 076 list_host = host.run('stack list vm output-format=json')77 assert list_host.rc == 078 assert json.loads(list_host.stdout) == [79 {80 'virtual machine': 'vm-backend-0-3',81 'hypervisor': 'hypervisor-0-1',82 'memory': 2048,83 'cpu': 1,84 'pending deletion': False85 },86 {87 'virtual machine': 'vm-backend-0-4',88 'hypervisor': 'hypervisor-0-1',89 'memory': 2048,90 'cpu': 2,91 'pending deletion': True92 },93 {94 'virtual machine': 'vm-backend-0-5',95 'hypervisor': 'hypervisor-0-2',96 'memory': 3072,97 'cpu': 3,98 'pending deletion': False99 }...
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!!