Ejemplo n.º 1
0
 def test_handle_error_no_channels(self, mock_send):
     error = mock_data.get_error()
     os.environ[environment.SLACK_WEB_HOOK] = (
         'https://hooks.slack.com/services/'
         'T02KE/B4PH1/VmEd2c7')
     os.environ[environment.SLACK_CHANNELS] = '#zermatt,#developers'
     del os.environ[environment.SLACK_CHANNEL_OVERRIDE]
     error['slackChannels'] = None
     slack_error.handle_error(error)
     error_message = slack_error.create_error_message(error)
     payload_1 = {
         "channel": '#zermatt',
         "text": error_message,
         "username": '******',
         "icon_emoji": ':no_entry:'
     }
     payload_2 = {
         "channel": '#developers',
         "text": error_message,
         "username": '******',
         "icon_emoji": ':no_entry:'
     }
     calls = [
         call('#zermatt',
              'https://hooks.slack.com/services/T02KE/B4PH1/VmEd2c7',
              payload_1),
         call('#developers',
              'https://hooks.slack.com/services/T02KE/B4PH1/VmEd2c7',
              payload_2),
     ]
     mock_send.assert_has_calls(calls, any_order=True)
Ejemplo n.º 2
0
 def test_validate_error(self):
     validation_url = environment.get_env_with_default_value(
         environment.VALIDATE_DEPLOYMENT_URL,
         'https://app.kth.se/jsonschema/dizin/error'
     )
     deployment_json = mock_data.get_error()
     result = requests.post(validation_url, json=deployment_json, allow_redirects=False)
     self.assertEqual(result.json(), {})
     self.assertEqual(result.status_code, 200)
Ejemplo n.º 3
0
 def test_create_error_message_no_stack_trace(self):
     error = mock_data.get_error()
     error['stackTrace'] = None
     message = slack_error.create_error_message(error)
     self.assertEqual(message, 'An error occured')
Ejemplo n.º 4
0
 def test_create_error_message(self):
     error = mock_data.get_error()
     message = slack_error.create_error_message(error)
     self.assertEqual(
         message, '*An error occured* \n'
         '```\nThis is a multiline\nstack trace\n```')