Esempio n. 1
0
class FindPersonsByTalentTest(unittest.TestCase):

    @patch('slackclient.SlackClient')
    @patch('trello.TrelloClient')
    def setUp(self, slack, trello):
        self.command = FindPersonsByTalent(slack, trello)

    def test_shouldTriggerOnMessageContainingTalentKeywordAndName(self):
        slackMsg = '{"user":"******","text":"talent Java","channel":"C123"}'
        eventData = SlackEvent(json.loads(slackMsg))
        self.command.slack.api_call = MagicMock(return_value=defaultSlackResponse)
        self.command.slack.rtm_send_message = MagicMock(return_value=None)
        self.command.trello.getTalentsByEmail = MagicMock(return_value='')

        result = self.command.shouldTriggerOn(eventData)

        self.assertTrue(result)

    def test_shouldNotTriggerOnMessageMissingKeyword(self):
        slackMsg = '{"user":"******","text":"blab Java","channel":"C123"}'
        eventData = SlackEvent(json.loads(slackMsg))
        self.command.slack.api_call = MagicMock(return_value=defaultSlackResponse)
        self.command.slack.rtm_send_message = MagicMock(return_value=None)
        self.command.trello.getTalentsByEmail = MagicMock(return_value='')

        result = self.command.shouldTriggerOn(eventData)

        self.assertFalse(result)

    def test_shouldSendErrorMessageIfTalentNotFound(self):
        slackMsg = '{"user":"******","text":"talent","channel":"C123"}'
        eventData = SlackEvent(json.loads(slackMsg))
        self.command.slack.api_call = MagicMock(return_value=defaultSlackResponse)
        self.command.slack.rtm_send_message = MagicMock(return_value=None)
        self.command.trello.getPersonEmailsByTalent2 = MagicMock(return_value='')

        result = self.command.executeOn(eventData)

        self.assertFalse(result)
        self.command.slack.rtm_send_message.assert_called_with("C123", "Talang saknas i meddelandetexten")
Esempio n. 2
0
 def setUp(self, slack, trello):
     self.command = FindPersonsByTalent(slack, trello)