Exemplo n.º 1
0
def test_send_async_true(email_kwargs, mocker):
    """
    GIVEN a need to create and send an email message
    WHEN api.send() is called
    THEN assert first the factory function returns a valid message instance
    """
    kwargs = email_kwargs
    fact_mock = mocker.patch.object(messages.api, 'message_factory')
    send('email', send_async=True, **kwargs)
    assert fact_mock.call_count == 1
Exemplo n.º 2
0
def test_send_raisesMessSendErr(mocker):
    """
    GIVEN a call to api.send()
    WHEN a message encounters a send() error
    THEN assert SystemExit is raised
    """
    fact_mock = mocker.patch.object(messages.api, 'message_factory')
    fact_mock.return_value.send.side_effect = MessageSendError('login fail')
    with pytest.raises(SystemExit):
        kwargs = email_kwargs
        send('email', **kwargs)