Best Python code snippet using tempest_python
test_service.py
Source: test_service.py
...57 self.assertRaises(exception.ServiceNotFound,58 self.dbapi.get_service_by_uuid,59 self.context,60 magnum_utils.generate_uuid())61 def test_get_service_list(self):62 uuids = [self.service.uuid]63 for i in range(1, 6):64 service = utils.create_test_service(65 bay_uuid=self.bay.uuid,66 uuid=magnum_utils.generate_uuid())67 uuids.append(six.text_type(service.uuid))68 res = self.dbapi.get_service_list(self.context)69 res_uuids = [r.uuid for r in res]70 self.assertEqual(sorted(uuids), sorted(res_uuids))71 def test_get_service_list_sorted(self):72 uuids = [self.service.uuid]73 for _ in range(5):74 service = utils.create_test_service(75 uuid=magnum_utils.generate_uuid())76 uuids.append(six.text_type(service.uuid))77 res = self.dbapi.get_service_list(self.context, sort_key='uuid')78 res_uuids = [r.uuid for r in res]79 self.assertEqual(sorted(uuids), res_uuids)80 self.assertRaises(exception.InvalidParameterValue,81 self.dbapi.get_service_list,82 self.context,83 sort_key='foo')84 def test_get_service_list_with_filters(self):85 bay1 = utils.get_test_bay(id=11, uuid=magnum_utils.generate_uuid())86 bay2 = utils.get_test_bay(id=12, uuid=magnum_utils.generate_uuid())87 self.dbapi.create_bay(bay1)88 self.dbapi.create_bay(bay2)89 service1 = utils.create_test_service(90 name='service-one',91 uuid=magnum_utils.generate_uuid(),92 bay_uuid=bay1['uuid'],93 ports=[{'port': 8000}])94 service2 = utils.create_test_service(95 name='service-two',96 uuid=magnum_utils.generate_uuid(),97 bay_uuid=bay2['uuid'],98 ports=[{'port': 8001}])99 res = self.dbapi.get_service_list(self.context,100 filters={'bay_uuid': bay1['uuid']})101 self.assertEqual([service1.id], [r.id for r in res])102 res = self.dbapi.get_service_list(self.context,103 filters={'bay_uuid': bay2['uuid']})104 self.assertEqual([service2.id], [r.id for r in res])105 res = self.dbapi.get_service_list(self.context,106 filters={'name': 'service-one'})107 self.assertEqual([service1.id], [r.id for r in res])108 res = self.dbapi.get_service_list(self.context,109 filters={'name': 'bad-service'})110 self.assertEqual([], [r.id for r in res])111 res = self.dbapi.get_service_list(self.context,112 filters={'ports': [{'port': 8000}]})113 self.assertEqual([service1.id], [r.id for r in res])114 res = self.dbapi.get_service_list(self.context,115 filters={'ports': [{'port': 8001}]})116 self.assertEqual([service2.id], [r.id for r in res])117 def test_get_service_list_bay_not_exist(self):118 res = self.dbapi.get_service_list(self.context, filters={119 'bay_uuid': self.bay.uuid})120 self.assertEqual(1, len(res))121 res = self.dbapi.get_service_list(self.context, filters={122 'bay_uuid': magnum_utils.generate_uuid()})123 self.assertEqual(0, len(res))124 def test_get_services_by_bay_uuid(self):125 res = self.dbapi.get_services_by_bay_uuid(self.context,126 self.bay.uuid)127 self.assertEqual(self.service.id, res[0].id)128 def test_get_services_by_bay_uuid_that_does_not_exist(self):129 self.assertRaises(exception.BayNotFound,130 self.dbapi.get_services_by_bay_uuid,131 self.context,132 magnum_utils.generate_uuid())133 def test_destroy_service(self):134 self.dbapi.destroy_service(self.service.id)135 self.assertRaises(exception.ServiceNotFound,...
services.py
Source: services.py
...10from datetime import timedelta, datetime11SERVICES_TAG = 'OPS_SERVICES_TAG'12MAX_SERVICES_CACHE_SIZE = 31314def get_service_list(maxage=timedelta(seconds=0), targetID=None, use_volatile=False):15 command = ops.cmd.getDszCommand('services')16 return ops.project.generic_cache_get(command, cache_tag=SERVICES_TAG, cache_size=2, maxage=maxage, targetID=targetID, use_volatile=use_volatile).service1718def get_running_services(maxage=timedelta(seconds=0), targetID=None, use_volatile=False):19 servlist = get_service_list(maxage=maxage, targetID=targetID)
...
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!!