def test_backend_check_fails_if_request_fails(self, request_mock):
        request_mock.side_effect = requests.exceptions.ConnectionError()

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset(
            {
                "status": "unhealthy",
                "response": "ConnectionError"
            }, result)
Ejemplo n.º 2
0
def healthcheck():
    response = {
        "disk": healthchecks.check_disk(),
        "Backend API test": healthchecks.check_backend_api()
    }
    ok = all(item["status"] == healthchecks.HEALTHY
             for _key, item in response.iteritems())
    result = jsonify(response)
    result.status_code = 200 if ok else 503
    return result
    def test_backend_check_passes_if_backend_is_healthy(self, request_mock):
        request_mock.return_value.ok = True
        request_mock.return_value.json.return_value = {"status": "UP"}

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset(
            {
                "status": "healthy",
                "response": {
                    "status": "UP"
                }
            }, result)
    def test_backend_check_fails_if_backend_is_unhealthy(self, request_mock):
        request_mock.return_value.ok = False
        request_mock.return_value.json.return_value = {"status": "DOWN"}

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset(
            {
                "status": "unhealthy",
                "response": {
                    "status": "DOWN"
                }
            }, result)
Ejemplo n.º 5
0
def healthcheck():
    response = {"disk": healthchecks.check_disk(), "Backend API test": healthchecks.check_backend_api()}
    ok = all(item["status"] == healthchecks.HEALTHY for _key, item in response.iteritems())
    result = jsonify(response)
    result.status_code = 200 if ok else 503
    return result
    def test_backend_check_passes_if_backend_is_healthy(self, request_mock):
        request_mock.return_value.ok = True
        request_mock.return_value.json.return_value = {"status": "UP"}

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset({"status": "healthy", "response": {"status": "UP"}}, result)
    def test_backend_check_fails_if_backend_is_unhealthy(self, request_mock):
        request_mock.return_value.ok = False
        request_mock.return_value.json.return_value = {"status": "DOWN"}

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset({"status": "unhealthy", "response": {"status": "DOWN"}}, result)
    def test_backend_check_fails_if_request_fails(self, request_mock):
        request_mock.side_effect = requests.exceptions.ConnectionError()

        result = healthchecks.check_backend_api()
        self.assertDictContainsSubset({"status": "unhealthy", "response": "ConnectionError"}, result)