"""
QA: GET draft bundle returns 200 with empty tabs when nothing is stored yet.

Run: cd be0 && python -m unittest tests.test_application_drafts_get -v
"""

from __future__ import annotations

import unittest
from unittest.mock import patch

_CASE = "CASE-1776577845956"


class ApplicationDraftsGetTests(unittest.TestCase):
    @patch("src.initiative_db.engine.is_postgres_enabled", return_value=False)
    @patch("main._load_application_draft_yaml", return_value=None)
    def test_unknown_case_returns_200_empty_shape(self, _mock_yaml, _mock_pg) -> None:
        from fastapi.testclient import TestClient

        from main import app

        client = TestClient(app)
        r = client.get(f"/api/v1/application-drafts/{_CASE}")
        self.assertEqual(r.status_code, 200, r.text)
        body = r.json()
        self.assertEqual(body.get("caseId"), _CASE)
        self.assertEqual(body.get("tabs"), {})
        self.assertIn("updatedAt", body)


if __name__ == "__main__":
    unittest.main()
