Best Python code snippet using tempest_python
test_simple_tenant_usage.py
Source:test_simple_tenant_usage.py
...44 # Get usage for all tenants45 params = {'start': self.start,46 'end': self.end,47 'detailed': int(bool(True))}48 resp, tenant_usage = self.adm_client.list_tenant_usages(params)49 self.assertEqual(200, resp.status)50 self.assertEqual(len(tenant_usage), 8)51 @attr(type='gate')52 def test_get_usage_tenant(self):53 # Get usage for a specific tenant54 params = {'start': self.start,55 'end': self.end}56 resp, tenant_usage = self.adm_client.get_tenant_usage(57 self.tenant_id, params)58 self.assertEqual(200, resp.status)59 self.assertEqual(len(tenant_usage), 8)60 @attr(type='gate')61 def test_get_usage_tenant_with_non_admin_user(self):62 # Get usage for a specific tenant with non admin user...
tenant_usages_client.py
Source:tenant_usages_client.py
...16from six.moves.urllib import parse as urllib17from automation.api_schema.response.compute.v2_1 import tenant_usages as schema18from automation.common import service_client19class TenantUsagesClient(service_client.ServiceClient):20 def list_tenant_usages(self, **params):21 url = 'os-simple-tenant-usage'22 if params:23 url += '?%s' % urllib.urlencode(params)24 resp, body = self.get(url)25 body = json.loads(body)26 self.validate_response(schema.list_tenant_usage, resp, body)27 return service_client.ResponseBodyList(resp, body['tenant_usages'][0])28 def show_tenant_usage(self, tenant_id, **params):29 url = 'os-simple-tenant-usage/%s' % tenant_id30 if params:31 url += '?%s' % urllib.urlencode(params)32 resp, body = self.get(url)33 body = json.loads(body)34 self.validate_response(schema.get_tenant_usage, resp, body)...
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!!