diff --git a/backend/tests/unit_tests/test_api_health.py b/backend/tests/unit_tests/test_api_health.py new file mode 100644 index 0000000..d3602f0 --- /dev/null +++ b/backend/tests/unit_tests/test_api_health.py @@ -0,0 +1,45 @@ +# coding=utf-8 + +# Copyright [2024] [SkywardAI] +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest +import fastapi +from fastapi.testclient import TestClient +import httpx +from src.api.routes import health + + +class TestAPIHealth(unittest.TestCase): + """ + Test the FastAPI application attributes + """ + + @classmethod + def setUpClass(cls): + cls.app = fastapi.FastAPI() + cls.app.include_router(health.router) + cls.client = TestClient(cls.app) + + @classmethod + def tearDownClass(cls): + pass + + def test_api_health(self): + """ + Test the health check API + """ + response: httpx.Response = self.client.get("/health") + self.assertIsInstance(response, httpx.Response) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.json(), {"status": "ok"})