def test_create_inbound_mmg_sms_object(sample_service_full_permissions):
    data = {
        'Message': 'hello+there+%F0%9F%93%A9',
        'Number': sample_service_full_permissions.get_inbound_number(),
        'MSISDN': '447700900001',
        'DateRecieved': '2017-01-02+03%3A04%3A05',
        'ID': 'bar',
    }

    inbound_sms = create_inbound_sms_object(
        sample_service_full_permissions,
        format_mmg_message(data["Message"]),
        data["MSISDN"],
        data["ID"],
        format_mmg_datetime(data["DateRecieved"]),
        "mmg"
    )

    assert inbound_sms.service_id == sample_service_full_permissions.id
    assert inbound_sms.notify_number == sample_service_full_permissions.get_inbound_number()
    assert inbound_sms.user_number == '447700900001'
    assert inbound_sms.provider_date == datetime(2017, 1, 2, 8, 4, 5)
    assert inbound_sms.provider_reference == 'bar'
    assert inbound_sms._content != 'hello there 📩'
    assert inbound_sms.content == 'hello there 📩'
    assert inbound_sms.provider == 'mmg'
Ejemplo n.º 2
0
def test_create_inbound_mmg_sms_object_uses_inbound_number_if_set(
        sample_service_full_permissions):
    sample_service_full_permissions.sms_sender = 'foo'
    inbound_number = sample_service_full_permissions.get_inbound_number()

    data = {
        'Message': 'hello+there+%F0%9F%93%A9',
        'Number': sample_service_full_permissions.get_inbound_number(),
        'MSISDN': '07700 900 001',
        'DateRecieved': '2017-01-02+03%3A04%3A05',
        'ID': 'bar',
    }

    inbound_sms = create_inbound_sms_object(
        sample_service_full_permissions,
        format_mmg_message(data["Message"]), data["MSISDN"], data["ID"],
        format_mmg_datetime(data["DateRecieved"]), "mmg")

    assert inbound_sms.service_id == sample_service_full_permissions.id
    assert inbound_sms.notify_number == inbound_number
Ejemplo n.º 3
0
def test_format_mmg_datetime(provider_date, expected_output):
    assert format_mmg_datetime(provider_date) == expected_output
Ejemplo n.º 4
0
def test_format_mmg_datetime_returns_now_if_cannot_parse_date():
    assert format_mmg_datetime('13-05-2020 08%3A37%3A43') == datetime.utcnow()