Ejemplo n.º 1
0
def test_send_welcome_sms(mocker, test_client, init_database, mock_sms_apis,
                          preferred_language, org_key, expected_welcome,
                          expected_terms, phone):
    from flask import g
    from server import db

    token = TokenFactory(name='Sarafu', symbol='Sarafu')
    organisation = OrganisationFactory(custom_welcome_message_key=org_key,
                                       token=token,
                                       country_code='AU')
    g.active_organisation = organisation
    transfer_account = TransferAccountFactory(token=token,
                                              organisation=organisation)
    transfer_account.set_balance_offset(10000)
    user = UserFactory(first_name='Magoo',
                       phone=phone,
                       preferred_language=preferred_language,
                       organisations=[organisation],
                       default_organisation=organisation,
                       transfer_accounts=[transfer_account])
    send_onboarding_sms_messages(user)

    messages = mock_sms_apis
    assert messages == [
        {
            'phone': f'+61{phone}',
            'message': expected_welcome
        },
        {
            'phone': f'+61{phone}',
            'message': expected_terms
        },
    ]
Ejemplo n.º 2
0
def test_send_welcome_sms(mocker, test_client, init_database,
                          preferred_language, org_key, expected_welcome, expected_terms):
    from flask import g

    token = TokenFactory(name='Sarafu', symbol='SARAFU')
    organisation = OrganisationFactory(custom_welcome_message_key=org_key, token=token, country_code='AU')
    g.active_organisation = organisation
    transfer_account = TransferAccountFactory(balance=10000, token=token, organisation=organisation)
    user = UserFactory(first_name='Magoo',
                       phone='123456789',
                       preferred_language=preferred_language,
                       organisations=[organisation],
                       default_organisation=organisation,
                       transfer_accounts=[transfer_account])

    send_message = mocker.MagicMock()
    mocker.patch('server.message_processor.send_message', send_message)

    send_onboarding_sms_messages(user)

    send_message.assert_has_calls(
        [mocker.call('+61123456789', expected_welcome),
         mocker.call('+61123456789', expected_terms)])