Best Python code snippet using tempest_python
conftest.py
Source:conftest.py
...48 tenant_data = dict(kind='partner', name='test_name')49 tenant = create_tenant(client, tenant_data)50 yield tenant51 # teardown52 assert disable_tenant(client, tenant['id'])53 assert delete_tenant(client, tenant['id'])54@pytest.fixture55def customer_tenant():56 client = Client(grant_type=GrantType.client_credentials)57 tenant_data = dict(kind='customer', name='test_customer_name')58 tenant = create_tenant(client, tenant_data)59 yield tenant60 # teardown61 assert disable_tenant(client, tenant['id'])62 assert delete_tenant(client, tenant['id'])63@pytest.fixture64def tenant_all_app_enabled(tenant):65 client = Client(grant_type=GrantType.client_credentials)66 items = get_available_items(client, client.tenant_id)67 offer_items(client, tenant['id'], dict(offering_items=items))68 yield tenant69@pytest.fixture70def client():71 auth_client = Client(grant_type=GrantType.client_credentials)72 client = create_client(auth_client, client_type='agent')73 yield client74 # teardown75 assert delete_client(auth_client, client['client_id'])...
how_to_disable_tenant.py
Source:how_to_disable_tenant.py
...16 headers=client.auth_header,17 )18 handle_error_response(response)19 return response.json()20def disable_tenant(client: Client, tenant_id: str) -> bool:21 """Disables the tenant via the `/tenants/{tenant_id}` endpoint22 :param client: Client object23 :param tenant_id: The ID of the tenant24 :return: `True` if succeeded, `False` otherwise25 """26 payload = {27 'enabled': False,28 'version': get_tenant_info(client, tenant_id)['version'],29 }30 response = requests.put(31 f'{client.base_url}/api/2/tenants/{tenant_id}',32 headers=client.auth_header,33 json=payload,34 )35 handle_error_response(response)36 return response.status_code == 20037def main(args):38 client = Client(grant_type=GrantType.client_credentials)39 assert disable_tenant(client, args.tenant_id)40if __name__ == '__main__':41 args = parse_arguments(('tenant-id', True))...
config_alloc.py
Source:config_alloc.py
1from ConfigParser import SafeConfigParser2class GetOptions():3 try:4 config_file = '/tmp/alloca-config.ini'5 with open(config_file):6 parser = SafeConfigParser()7 parser.read(config_file)8 except IOError:9 print "Error!, Config File Not found at (/tmp/alloca-config.ini)"10 raise SystemExit11 def process_config(self, section, option):12 for section_name in self.parser.sections():13 try:14 if section_name == section:15 list_items = self.parser.get(section_name, option)16 except:17 list_items = None18 return list_items19 return list_items20class GetVar(object):21 def __init__(self):22 func = GetOptions()23 self.username = func.process_config('cred', 'user')24 self.passwd = func.process_config('cred', 'passwd')25 self.name = func.process_config('cred', 'name')26 self.url = func.process_config('cred', 'url')27 self.disable_tenant = func.process_config('tenant', 'id')28 self.csv_dir = func.process_config('csv', 'file')...
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!!