def test_get_task_info_visit_staged(self, request_mock, *_): status = testdata_helper.get_status() staged_status = testdata_helper.get_status(status="ERROR") request_mock.register_uri('GET', "http://name.vertical.group.some-domain.com/service/internal/status", text=json.dumps(status), headers={'x-color': 'BLU'}) request_mock.register_uri('GET', "http://staged.name.vertical.group.some-domain.com/service/internal/status", text=json.dumps(staged_status), headers={'x-color': 'BLU'}) expected_inactive = testdata_helper.get_task(id="/group/vertical/name/GRN", app_status=3, status=3, severity=30, active_color="BLU", color="GRN", status_url='http://staged.name.vertical.group.some-domain.com/service/internal/status', marathon_link='http://some-marathon.com/ui/#/apps/%2Fgroup%2Fvertical%2Fname%2FGRN') expected_active = testdata_helper.get_task(id="/group/vertical/name/BLU", active_color="BLU", color="BLU", status_url='http://name.vertical.group.some-domain.com/service/internal/status', marathon_link='http://some-marathon.com/ui/#/apps/%2Fgroup%2Fvertical%2Fname%2FBLU') app_inactive = self.app.copy() app_inactive["id"] = "/group/vertical/name/GRN" app_active = self.app.copy() app_active["id"] = "/group/vertical/name/BLU" self.assertDictEqual(expected_inactive, update.get_task_info(app_inactive, self.marathon)) self.assertDictEqual(expected_active, update.get_task_info(app_active, self.marathon)) self.assertEquals(3, len(request_mock.request_history)) self.assertEquals("http://name.vertical.group.some-domain.com/service/internal/status", request_mock.request_history[0].url) self.assertEquals("http://staged.name.vertical.group.some-domain.com/service/internal/status", request_mock.request_history[1].url) self.assertEquals("http://name.vertical.group.some-domain.com/service/internal/status", request_mock.request_history[2].url)
def test_get_task_info_status_page_503(self, *_): expected = testdata_helper.get_task(status=3, app_status=1, severity=30, status_page_status_code=503, version="UNKNOWN", active_color=None, jobs={}) self.assertDictEqual(expected, update.get_task_info(self.app, self.marathon))
def test_get_task_info_suspended(self, _): expected = testdata_helper.get_task(status=1, app_status=1, severity=1, status_page_status_code=None, version="UNKNOWN", active_color=None, jobs={}, instances=0) app = self.app.copy() app["instances"] = 0 self.assertDictEqual(expected, update.get_task_info(app, self.marathon))
def test_get_task_info_no_status_page(self, *_): expected = testdata_helper.get_task(status=1, app_status=1, severity=1, status_url='', status_page_status_code=None, version="UNKNOWN", active_color=None, jobs={}) app = self.app.copy() app.pop("env") self.assertDictEqual(expected, update.get_task_info(app, self.marathon))
def test_get_task_info_with_out_color(self, request_mock, *_): status = testdata_helper.get_status() request_mock.register_uri('GET', "http://name.vertical.group.some-domain.com/service/internal/status", text=json.dumps(status), headers={'x-color': 'GRN'}) expected = testdata_helper.get_task() self.assertDictEqual(expected, update.get_task_info(self.app, self.marathon)) self.assertEquals(1, len(request_mock.request_history)) self.assertEquals("http://name.vertical.group.some-domain.com/service/internal/status", request_mock.request_history[0].url)
def test_get_task_info_status_page_503_in_live(self, *_): expected = testdata_helper.get_task(id='/live/vertical/name', group='live', status_url='http://name.vertical.live.some-domain.com/service/internal/status', marathon_link='http://some-marathon.com/ui/#/apps/%2Flive%2Fvertical%2Fname', status=3, app_status=1, severity=3000, status_page_status_code=503, version="UNKNOWN", active_color=None, jobs={}) live_app = self.app.copy() live_app["id"] = "/live/vertical/name" self.assertDictEqual(expected, update.get_task_info(live_app, self.marathon))
def test_get_task_info_job_does_not_change(self, *_): expected = testdata_helper.get_task() self.assertDictEqual(expected, update.get_task_info(self.app, self.marathon))