feat(headless): Implement Phase 1 - Project Setup & Headless Scaffold
This commit is contained in:
35
tests/test_headless_api.py
Normal file
35
tests/test_headless_api.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import unittest
|
||||
from fastapi.testclient import TestClient
|
||||
import gui_2
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
class TestHeadlessAPI(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# We need an App instance to initialize the API, but we want to avoid GUI stuff
|
||||
with patch('gui_2.session_logger.open_session'), \
|
||||
patch('gui_2.ai_client.set_provider'), \
|
||||
patch('gui_2.session_logger.close_session'):
|
||||
cls.app_instance = gui_2.App()
|
||||
# We will implement create_api method in App
|
||||
if hasattr(cls.app_instance, 'create_api'):
|
||||
cls.api = cls.app_instance.create_api()
|
||||
else:
|
||||
cls.api = MagicMock()
|
||||
cls.client = TestClient(cls.api)
|
||||
|
||||
def test_health_endpoint(self):
|
||||
response = self.client.get("/health")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json(), {"status": "ok"})
|
||||
|
||||
def test_status_endpoint(self):
|
||||
response = self.client.get("/status")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
data = response.json()
|
||||
self.assertIn("provider", data)
|
||||
self.assertIn("model", data)
|
||||
self.assertIn("active_project", data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user