Best Python code snippet using tempest_python
test_simple_tenant_usage.py
Source:test_simple_tenant_usage.py
...37 @classmethod38 def _parse_strtime(cls, at):39 # Returns formatted datetime40 return at.strftime('%Y-%m-%dT%H:%M:%S.%f')41 def call_until_valid(self, func, duration, *args, **kwargs):42 # Call until get valid response for "duration"43 # because tenant usage doesn't become available immediately44 # after create VM.45 def is_valid():46 try:47 self.resp = func(*args, **kwargs)48 return True49 except e.InvalidHTTPResponseBody:50 return False51 test.call_until_true(is_valid, duration, 1)52 return self.resp53 @test.idempotent_id('062c8ae9-9912-4249-8b51-e38d664e926e')54 def test_list_usage_all_tenants(self):55 # Get usage for all tenants56 tenant_usage = self.call_until_valid(57 self.adm_client.list_tenant_usages, VALID_WAIT,58 start=self.start, end=self.end, detailed="1")['tenant_usages'][0]59 self.assertEqual(len(tenant_usage), 8)60 @test.idempotent_id('94135049-a4c5-4934-ad39-08fa7da4f22e')61 def test_get_usage_tenant(self):62 # Get usage for a specific tenant63 tenant_usage = self.call_until_valid(64 self.adm_client.show_tenant_usage, VALID_WAIT,65 self.tenant_id, start=self.start, end=self.end)['tenant_usage']66 self.assertEqual(len(tenant_usage), 8)67 @test.idempotent_id('9d00a412-b40e-4fd9-8eba-97b496316116')68 def test_get_usage_tenant_with_non_admin_user(self):69 # Get usage for a specific tenant with non admin user70 tenant_usage = self.call_until_valid(71 self.client.show_tenant_usage, VALID_WAIT,72 self.tenant_id, start=self.start, end=self.end)['tenant_usage']...
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!!