Пример #1
0
 def test_format_descr_wo_notes(self):
     """
     Tests the _format_description method when the alert has no notes.
     """
     self.mock_settings['INCLUDE_FULL_DESCRIPTION'] = False
     with patch('ambassador.transport.Transport.get_key_cert',
                return_value=self.mock_cert):
         with patch('platforms.jira.handlers.jira.JIRA',
                    return_value=self.mock_auth):
             with patch.dict('platforms.jira.handlers.settings.JIRA',
                             self.mock_settings):
                 handler_w_user = IssueAPI(endpoint=self.endpoint,
                                           user=self.user)
                 alert = Alert.objects.get(pk=2)
                 actual = handler_w_user._format_description(alert)
                 expected = ''
     self.assertEqual(actual, expected)
Пример #2
0
    def test_format_full_description(self):
        """
        Tests the _format_description method when a full description
        is used and empty fields are included.
        """
        with patch('ambassador.transport.Transport.get_key_cert',
                   return_value=self.mock_cert):
            with patch('platforms.jira.handlers.jira.JIRA',
                       return_value=self.mock_auth):
                with patch.dict('platforms.jira.handlers.settings.JIRA',
                                self.mock_settings):
                    handler_w_user = IssueAPI(endpoint=self.endpoint,
                                              user=self.user)
                    alert = Alert.objects.get(pk=2)
                    alert.data = self.mock_data
                    actual = handler_w_user._format_description(alert)
                    expected = """\
{code:bgColor=#f5f5f5|title=Test Alert|titleBGColor=#dcdcdc}
Alert ID:     2
Title:        Threat Alert
Level:        HIGH
Incidents:    1
Created date: 2015-03-01 02:41:24.468404+00:00

Collection:   mongodb.test_database.test_posts
Document ID:  2
Source Data:  
{
    "host": "foo",
    "message": "bar"
}

Notes:        
None

-----

John Smith commented at 2015-03-01 02:43:24.468404+00:00:
This alert isn't this important
{code}"""
                    self.assertEqual(actual, expected)