def test_get_health_response_execute(self): """ get_health_response executes the given function """ health_check = Mock() get_health_response(health_check, SUCCESS_MESSAGE) health_check.assert_called()
def test_get_health_response_fail(self): """ get_health_response should return a 500 status code if the given health_checks fails """ health_check = Mock(side_effect=Exception(ERROR_MESSAGE)) response = get_health_response(health_check, SUCCESS_MESSAGE) self.assertEquals(response.status_code, 500)
def test_get_health_response_success_message(self): """ get_health_response should return the given success message if the health check succeeds """ health_check = Mock() response = get_health_response(health_check, SUCCESS_MESSAGE) self.assertEquals(json.loads(response.content), SUCCESS_MESSAGE)
def test_get_health_response_success(self): """ get_health_response should return a 200 status code if the given health_checks succeeds """ health_check = Mock() response = get_health_response(health_check, SUCCESS_MESSAGE) self.assertEquals(response.status_code, 200)
def test_get_health_response_fail_message(self): """ get_health_response should return a fail message if the health check fails """ health_check = Mock(side_effect=Exception(ERROR_MESSAGE)) response = get_health_response(health_check, SUCCESS_MESSAGE) self.assertEquals(json.loads(response.content), {"error": ERROR_MESSAGE})
def health_bwv(request): sync_times = get_bwv_sync_times() sync_times = [ {"start": str(sync_time["start"]), "finished": str(sync_time["finished"])} for sync_time in sync_times ] success_dict = SUCCESS_DICTIONARY_BWV.copy() success_dict["sync_times"] = sync_times return get_health_response(assert_bwv_health, success_dict)
def health_default(request): def assert_default_health(): assert_health_generic(database_name=settings.DEFAULT_DATABASE_NAME) return get_health_response(assert_default_health, SUCCESS_DICTIONARY_DEFAULT)