Exemple #1
0
def test_message_factory_twilio(twilio_kwargs, cfg_mock):
    """
    GIVEN a need to create a twilio message with the specified kwargs
    WHEN message_factory is called
    THEN assert a Twilio instance is returned
    """
    kwargs = twilio_kwargs
    msg = message_factory('twilio', **kwargs)
    assert isinstance(msg, Twilio)
Exemple #2
0
def test_message_factory_slackpost(slackpost_kwargs, cfg_mock):
    """
    GIVEN a need to create a slackpost message with the specified kwargs
    WHEN message_factory is called
    THEN assert a SlackPost instance is returned
    """
    kwargs = slackpost_kwargs
    msg = message_factory('slackpost', **kwargs)
    assert isinstance(msg, SlackPost)
Exemple #3
0
def test_message_factory_telegrambot(telegrambot_kwargs, cfg_mock):
    """
    GIVEN a need to create a telegrambot message with the specified kwargs
    WHEN message_factory is called
    THEN assert a TelegramBot instance is returned
    """
    kwargs = telegrambot_kwargs
    msg = message_factory('telegrambot', **kwargs)
    assert isinstance(msg, TelegramBot)
Exemple #4
0
def test_message_factory_email(email_kwargs, cfg_mock):
    """
    GIVEN a need to create an email message with the specified kwargs
    WHEN message_factory is called
    THEN assert an Email instance is returned
    """
    kwargs = email_kwargs
    msg = message_factory('email', **kwargs)
    assert isinstance(msg, Email)
Exemple #5
0
def test_message_factory_keyerror(email_kwargs, cfg_mock):
    """
    GIVEN a need to create a message object
    WHEN message_factory is called with an unsupported message type
    THEN assert UnsupportedMessageTypeError is raised
    """
    kwargs = email_kwargs
    with pytest.raises(UnsupportedMessageTypeError):
        msg = message_factory('bad', **kwargs)
Exemple #6
0
def test_message_factory_(msg_type, msg_class, msg_args, cfg_mock):
    """
    GIVEN a need to create a message with the specified kwargs
    WHEN message_factory is called
    THEN assert a valid instance instance is returned
    """
    kwargs = msg_args
    msg = message_factory(msg_type, **kwargs)
    assert isinstance(msg, msg_class)
Exemple #7
0
def test_message_factory_raisesUnkProfErr(cfg_mock):
    """
    GIVEN a need to create a message object
    WHEN message_factory is called with an unknown profile name
    THEN assert message is printed and SystemExit is raised
    """
    kwargs = email_kwargs
    kwargs['profile'] = str(uuid.uuid4())
    with pytest.raises(SystemExit):
        msg = message_factory('email', **kwargs)
Exemple #8
0
def test_message_factory_raisesInvalInpErr(cfg_mock):
    """
    GIVEN a need to create a message object
    WHEN message_factory is called with an invalid input type per the message
        class parameter requirements
    THEN assert message is printed and SystemExit is raised
    """
    kwargs = email_kwargs
    kwargs['to'] = 'not an email address'
    with pytest.raises(SystemExit):
        msg = message_factory('email', **kwargs)