def test_invalid_enable_email_link_sign_in(self, enable, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.update_tenant('tenant-id', enable_email_link_sign_in=enable, app=tenant_mgt_app) assert str( excinfo.value).startswith('Invalid type for enableEmailLinkSignin')
def test_invalid_allow_password_sign_up(self, allow, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.update_tenant('tenant-id', allow_password_sign_up=allow, app=tenant_mgt_app) assert str( excinfo.value).startswith('Invalid type for allowPasswordSignup')
def test_invalid_tenant_id(self, tenant_id, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.update_tenant(tenant_id, display_name='My Tenant', app=tenant_mgt_app) assert str( excinfo.value).startswith('Tenant ID must be a non-empty string')
def test_tenant_not_found_error(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.update_tenant('tenant', display_name='My-Tenant', 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 update_tenant(tenant_id): # [START update_tenant] tenant = tenant_mgt.update_tenant( tenant_id, display_name='updatedName', allow_password_sign_up=False) # Disable email provider print('Updated tenant:', tenant.tenant_id)
def test_update_tenant_minimal(self, tenant_mgt_app): _, recorder = _instrument_tenant_mgt(tenant_mgt_app, 200, GET_TENANT_RESPONSE) tenant = tenant_mgt.update_tenant('tenant-id', display_name='My-Tenant', app=tenant_mgt_app) _assert_tenant(tenant) body = {'displayName': 'My-Tenant'} mask = ['displayName'] self._assert_request(recorder, body, mask)
def test_update_tenant_false_values(self, tenant_mgt_app): _, recorder = _instrument_tenant_mgt(tenant_mgt_app, 200, GET_TENANT_RESPONSE) tenant = tenant_mgt.update_tenant('tenant-id', allow_password_sign_up=False, enable_email_link_sign_in=False, app=tenant_mgt_app) _assert_tenant(tenant) body = { 'allowPasswordSignup': False, 'enableEmailLinkSignin': False, } mask = ['allowPasswordSignup', 'enableEmailLinkSignin'] self._assert_request(recorder, body, mask)
def test_update_tenant(): tenant = tenant_mgt.create_tenant(display_name='py-update-test', allow_password_sign_up=True, enable_email_link_sign_in=True) try: tenant = tenant_mgt.update_tenant(tenant.tenant_id, display_name='updated-py-tenant', allow_password_sign_up=False, enable_email_link_sign_in=False) assert isinstance(tenant, tenant_mgt.Tenant) assert tenant.tenant_id == tenant.tenant_id assert tenant.display_name == 'updated-py-tenant' assert tenant.allow_password_sign_up is False assert tenant.enable_email_link_sign_in is False finally: tenant_mgt.delete_tenant(tenant.tenant_id)
def test_update_tenant(self, tenant_mgt_app): _, recorder = _instrument_tenant_mgt(tenant_mgt_app, 200, GET_TENANT_RESPONSE) tenant = tenant_mgt.update_tenant('tenant-id', display_name='My-Tenant', allow_password_sign_up=True, enable_email_link_sign_in=True, app=tenant_mgt_app) _assert_tenant(tenant) body = { 'displayName': 'My-Tenant', 'allowPasswordSignup': True, 'enableEmailLinkSignin': True, } mask = ['allowPasswordSignup', 'displayName', 'enableEmailLinkSignin'] self._assert_request(recorder, body, mask)
def test_update_tenant_no_args(self, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.update_tenant('tenant-id', app=tenant_mgt_app) assert str(excinfo.value).startswith( 'At least one parameter must be specified for update')
def test_invalid_display_name_value(self, display_name, tenant_mgt_app): with pytest.raises(ValueError) as excinfo: tenant_mgt.update_tenant('tenant-id', display_name=display_name, app=tenant_mgt_app) assert str(excinfo.value).startswith('displayName must start')