def test_tenant_not_found(self, tenant_mgt_app): _instrument_tenant_mgt(tenant_mgt_app, 500, TENANT_NOT_FOUND_RESPONSE) with pytest.raises(tenant_mgt.TenantNotFoundError) as excinfo: tenant_mgt.get_tenant('tenant-id', app=tenant_mgt_app) error_msg = 'No tenant found for the given identifier (TENANT_NOT_FOUND).' assert excinfo.value.code == exceptions.NOT_FOUND assert str(excinfo.value) == error_msg assert excinfo.value.http_response is not None assert excinfo.value.cause is not None
def test_get_tenant(sample_tenant): tenant = tenant_mgt.get_tenant(sample_tenant.tenant_id) assert isinstance(tenant, tenant_mgt.Tenant) assert tenant.tenant_id == sample_tenant.tenant_id assert tenant.display_name == 'admin-python-tenant' assert tenant.allow_password_sign_up is True assert tenant.enable_email_link_sign_in is True
def test_get_tenant(self, tenant_mgt_app): _, recorder = _instrument_tenant_mgt(tenant_mgt_app, 200, GET_TENANT_RESPONSE) tenant = tenant_mgt.get_tenant('tenant-id', app=tenant_mgt_app) _assert_tenant(tenant) assert len(recorder) == 1 req = recorder[0] assert req.method == 'GET' assert req.url == '{0}/tenants/tenant-id'.format(TENANT_MGT_URL_PREFIX)
def get_tenant(tenant_id): # [START get_tenant] tenant = tenant_mgt.get_tenant(tenant_id) print('Retreieved tenant:', tenant.tenant_id)
def test_delete_tenant(): tenant = tenant_mgt.create_tenant(display_name='py-delete-test') tenant_mgt.delete_tenant(tenant.tenant_id) with pytest.raises(tenant_mgt.TenantNotFoundError): tenant_mgt.get_tenant(tenant.tenant_id)
def test_invalid_tenant_id(self, tenant_id, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.get_tenant(tenant_id, app=tenant_mgt_app) assert str(excinfo.value).startswith('Invalid tenant ID')