def test_email_sent_when_all_provider_unavailable():
    emails_handler = EmailsHandler(
        MockUsersDao(), MockEmailsDao(),
        [BadMockEmailsProvider(),
         BadMockEmailsProvider()])

    event = assemble_request("/email/1/send",
                             method="POST",
                             headers={"api_key": "test_api_key"},
                             path_params={"email_id": 1})

    response = wrap_event(emails_handler.handle_send_email, event)

    code = response.status_code
    assert code is not None and code == 400
def test_email_sent_when_one_provider_unavailable():
    emails_handler = EmailsHandler(
        MockUsersDao(), MockEmailsDao(),
        [BadMockEmailsProvider(),
         SimpleMockEmailsProvider()])

    event = assemble_request("/email/1/send",
                             method="POST",
                             headers={"api_key": "test_api_key"},
                             path_params={"email_id": 1})

    response = wrap_event(emails_handler.handle_send_email, event)

    code = response.status_code
    assert code is not None and code == 200
    email = json.loads(response.body)
    assert email.get("id") is not None
    assert email.get("status") is not None and email.get(
        "status") == EmailStatus.ACCEPTED.name
Exemplo n.º 3
0
def sparkpsot_receive(event):
    return wrap_event(sparkpsot_receiver.handle, event)
Exemplo n.º 4
0
def mailgun_receive(event):
    return wrap_event(mailgun_receiver_handler.handle, event)
Exemplo n.º 5
0
def email_send(event):
    return wrap_event(emails_handler.handle_send_email, event)
Exemplo n.º 6
0
def email_get(event):
    return wrap_event(emails_handler.handle_get_email, event)
Exemplo n.º 7
0
def email_sent(event, **kwargs):
    return wrap_event(emails_handler.handle_create_email, event)
Exemplo n.º 8
0
def swagger_doc(event, **kwargs):
    return wrap_event(api_doc_handler.handle, event)