def test_get_links(self, mock_time): mock_time.utcnow.return_value = MOCKED_TIME iso8601_urlencoded = '%Y-%m-%dT%H:%M:%SZ'.replace(':', '%%3A') r_start = ( MOCKED_TIME + timedelta(minutes=settings.RESULT_RANGE_START) ).strftime(iso8601_urlencoded) r_end = ( MOCKED_TIME + timedelta(minutes=settings.RESULT_RANGE_END) ).strftime(iso8601_urlencoded) alamo_api_url = ( 'http://alamo.example.com' '/checks/e2e1ec23-707a-4382-a956-f0cf3276a1b8/' '?triggers=e2e1ec23-707a-4382-a956-f0cf3276a1b8' '&from={}&until={}' ).format(r_start, r_end) expected = { 'alamo_api_url': { 'href': alamo_api_url, 'type': 'link' }, 'trigger_url': { 'href': 'http://example.com/' '#/999/entity/888/check/982/?triggerId=2492', 'type': 'link' } } notification = HttpNotificationClient() result = notification.get_links( self.check.uuid, self.check.triggers[0] ) self.assertDictEqual(result, expected)
def test_merged_tags(self): notification = HttpNotificationClient() trigger = Trigger() expected_merged_tags = ['tag1', 'tag2', 'tag3'] result = notification.merged_tags(self.check, trigger) self.assertListEqual(sorted(expected_merged_tags), sorted(result))
def test_it_performs_post_request(self, post_mock): notification = HttpNotificationClient() notification.send(self.check, self.check.triggers[0], 'resolve') self.assertEqual(post_mock.call_count, 1)