def test_add_reaction(self): mock = MagicMock() chat_client = ChatClient(mock) self.assertTrue( chat_client.add_reaction(Constants.DUMMY, Constants.DUMMY, Constants.DUMMY)) self.assertTrue(mock.add_reaction.called)
def test_update_message(self): mock = MagicMock() chat_client = ChatClient(mock) self.assertTrue( chat_client.update_message(Constants.DUMMY, Constants.DUMMY, Constants.DUMMY, Constants.DUMMY)) self.assertTrue(mock.update_message.called)
def test_send_ephemeral_message(self): mock = MagicMock() chat_client = ChatClient(mock) self.assertTrue( chat_client.send_ephemeral_message(Constants.DUMMY, Constants.DUMMY, Constants.DUMMY)) self.assertTrue(mock.send_ephemeral_message.called)
def send_pipeline_message(_, message_type, alert_type): """ Send a Slack message with info from Jenkins pipeline""" environment = os.environ builder = MessageBuilder(message_type, environment) email = environment.get('CHANGE_AUTHOR_EMAIL', '') message = "Jenkins has an update: " attachments = builder.make_attachment() if alert_type == 'ALERT_USER': ChatClient().send_user_message(email, message, attachments=attachments) else: ChatClient().send_room_message(CHANNEL_NAME, message, attachments=attachments)
def send_direct_message(_, email, message): """ Send slack message to a user""" ChatClient().send_user_message(email, message)
def send_channel_message(_, channel_name, message): """ Send slack message to a channel""" ChatClient().send_room_message(channel_name, message)