def test_listen_no_handlers(self, mock_fedmsg, mock_handle_msg):
        """
        Test 'listen' function where suffix is not in handlers
        """
        # Set up return values
        mock_fedmsg.tail_messages.return_value = [
            ("dummy", "dummy", "mock_topic", self.mock_message)
        ]

        # Call the function
        m.listen(self.mock_config)

        # Assert everything was called correctly
        mock_handle_msg.assert_not_called()
    def test_listen_no_issue(self, mock_fedmsg, mock_handlers_issue,
                             mock_handle_msg):
        """
        Test 'listen' function where the handler returns none
        """
        # Set up return values
        mock_handlers_issue['github.issue.comment'].return_value = None
        mock_fedmsg.tail_messages.return_value = [
            ("dummy", "dummy", "d.d.d.pagure.issue.drop", self.mock_message)
        ]

        # Call the function
        m.listen(self.mock_config)

        # Assert everything was called correctly
        mock_handle_msg.assert_not_called()
    def test_listen(self, mock_fedmsg, mock_handlers_issue, mock_handle_msg):
        """
        Test 'listen' function where everything goes smoothly
        """
        # Set up return values
        mock_handlers_issue[
            'github.issue.comment'].return_value = 'dummy_issue'
        mock_fedmsg.tail_messages.return_value = [
            ("dummy", "dummy", "d.d.d.github.issue.comment", self.mock_message)
        ]

        # Call the function
        m.listen(self.mock_config)

        # Assert everything was called correctly
        mock_handle_msg.assert_called_with(self.mock_message,
                                           'github.issue.comment',
                                           self.mock_config)
Example #4
0
    def test_listen(self,
                    mock_fedmsg,
                    mock_d,
                    mock_u,
                    mock_handlers_issue):
        """
        Test 'listen' function where everything goes smoothly
        """
        # Set up return values
        mock_handlers_issue['github.issue.comment'].return_value = 'dummy_issue'
        mock_fedmsg.tail_messages.return_value = [("dummy", "dummy", "d.d.d.github.issue.comment", self.mock_message)]
        mock_u.handle_github_message.return_value = 'dummy_issue'

        # Call the function
        m.listen(self.mock_config)

        # Assert everything was called correctly
        mock_d.sync_with_jira.assert_called_with('dummy_issue', self.mock_config)
        mock_u.handle_pagure_message.assert_not_called()