def test_send_notifications_when_slack_call_fails(self):
        event = TestableEvent()
        handler = SlackHandler(event, self.config)

        mock_slack = self.mock_slack_response(
            fixture='responses/slack_post_message_failure.json')
        handler.slack.api_call = mock_slack

        sent = handler.send_notifications()
        eq_(sent, 0)
        ok_(mock_slack.called)
    def test_send_notifications_is_successful(self):
        event = TestableEvent()
        handler = SlackHandler(event, self.config)

        mock_slack = self.mock_slack_response()
        handler.slack.api_call = mock_slack
        sent = handler.send_notifications()
        eq_(sent, 1)

        ok_(mock_slack.called)
        mock_slack.assert_called_with(
            'chat.postMessage',
            channel='#Channel',
            icon_url='https://i.imgur.com/oEL0h26.jpg',
            link_names=True,
            mrkdwn=True,
            text=u':snowflake: *A wild PR from @slack-username appeared!* :snowflake:\n_title_: http://api.github.com/repos/dev/emojis/pulls/2964',
            unfurl_links=True,
            username='******')
 def test_send_notifications_ignores_events_it_should_not_handle(self):
     event = TestableEvent(action='closed')
     handler = SlackHandler(event, self.config)
     sent = handler.send_notifications()
     eq_(sent, 0)