コード例 #1
0
def test_client_doesnt_activate_if_already_active(mocker, api_user_active):
    mock_post = mocker.patch(
        'app.notify_client.user_api_client.UserApiClient.post')
    client = UserApiClient()

    client.activate_user(api_user_active)

    assert not mock_post.called
コード例 #2
0
def test_client_activates_if_pending(mocker, api_user_pending):
    mock_post = mocker.patch(
        'app.notify_client.user_api_client.UserApiClient.post')
    client = UserApiClient()
    client.max_failed_login_count = 1  # doesn't matter for this test

    client.activate_user(api_user_pending)

    mock_post.assert_called_once_with('/user/{}/activate'.format(
        api_user_pending.id),
                                      data=None)
コード例 #3
0
def test_client_updates_password_separately(mocker, api_user_active):
    expected_url = '/user/{}/update-password'.format(api_user_active.id)
    expected_params = {'_password': '******'}
    client = UserApiClient()
    client.max_failed_login_count = 1  # doesn't matter for this test
    mock_update_password = mocker.patch(
        'app.notify_client.user_api_client.UserApiClient.post')

    client.update_password(api_user_active.id, expected_params['_password'])
    mock_update_password.assert_called_once_with(expected_url,
                                                 data=expected_params)
コード例 #4
0
def test_client_uses_correct_find_by_email(mocker, api_user_active):

    expected_url = '/user/email'
    expected_params = {'email': api_user_active.email_address}

    client = UserApiClient()
    client.max_failed_login_count = 1  # doesn't matter for this test
    mock_get = mocker.patch('app.notify_client.user_api_client.UserApiClient.get')

    client.get_user_by_email(api_user_active.email_address)

    mock_get.assert_called_once_with(expected_url, params=expected_params)
コード例 #5
0
def test_client_uses_correct_find_by_email(mocker, api_user_active):

    expected_url = '/user/email'
    expected_params = {'email': api_user_active.email_address}

    client = UserApiClient()
    client.max_failed_login_count = 1  # doesn't matter for this test
    mock_get = mocker.patch(
        'app.notify_client.user_api_client.UserApiClient.get')

    client.get_user_by_email(api_user_active.email_address)

    mock_get.assert_called_once_with(expected_url, params=expected_params)
コード例 #6
0
ファイル: __init__.py プロジェクト: cds-snc/CANotifier
from app.notify_client.inbound_number_client import InboundNumberClient
from app.notify_client.billing_api_client import BillingAPIClient
from app.notify_client.complaint_api_client import complaint_api_client
from app.notify_client.platform_stats_api_client import (
    platform_stats_api_client,
)
from app.commands import setup_commands
from app.utils import requires_auth
from app.utils import get_cdn_domain
from app.utils import gmt_timezones

login_manager = LoginManager()
csrf = CSRFProtect()

service_api_client = ServiceAPIClient()
user_api_client = UserApiClient()
api_key_api_client = ApiKeyApiClient()
job_api_client = JobApiClient()
notification_api_client = NotificationApiClient()
support_api_client = SupportApiClient()
status_api_client = StatusApiClient()
invite_api_client = InviteApiClient()
template_statistics_client = TemplateStatisticsApiClient()
events_api_client = EventsApiClient()
provider_client = ProviderClient()
email_branding_client = EmailBrandingClient()
organisations_client = OrganisationsClient()
org_invite_api_client = OrgInviteApiClient()
asset_fingerprinter = AssetFingerprinter()
statsd_client = StatsdClient()
deskpro_client = DeskproClient()
コード例 #7
0
def test_client_only_updates_allowed_attributes(mocker):
    mocker.patch('app.notify_client.current_user', id='1')
    with pytest.raises(TypeError) as error:
        UserApiClient().update_user_attribute('user_id', id='1')
    assert str(error.value) == 'Not allowed to update user attributes: id'