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)
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)
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)
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)
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)
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)
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)
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)