예제 #1
0
 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()
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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})
예제 #6
0
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)
예제 #7
0
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)