1 line
27 KiB
JSON
1 line
27 KiB
JSON
{"repo": "chaokunhong/metascreener", "files": {"tests/unit/test_api_settings.py": {"532ee3cc10a7e22e54747d7c3413509c31b9a99b": {"t": 1785746912.4441488, "n": 6489, "h": "f76e29e753156a40", "c": "\"\"\"Tests for the settings API routes.\"\"\"\nfrom __future__ import annotations\n\nfrom pathlib import Path\nfrom unittest.mock import patch\n\nfrom fastapi.testclient import TestClient\n\n\nclass TestSettingsAPI:\n \"\"\"Test settings CRUD endpoints.\"\"\"\n\n def _client(self) -> TestClient:\n \"\"\"Create a test client for the FastAPI app.\n\n Returns:\n TestClient wired to the MetaScreener FastAPI app.\n \"\"\"\n from metascreener.api.main import create_app\n\n return TestClient(create_app())\n\n def test_get_settings_returns_defaults(self, tmp_path: Path) -> None:\n \"\"\"GET /api/settings returns default settings when no config exists.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert \"api_keys\" in data\n assert \"inference\" in data\n assert data[\"inference\"][\"temperature\"] == 0.0\n assert data[\"inference\"][\"seed\"] == 42\n\n def test_put_settings_updates_api_key(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings persists changes to disk.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"openrouter\": \"sk-test-123456789\"}},\n )\n assert resp.status_code == 200\n assert resp.json() == {\"status\": \"ok\"}\n assert (tmp_path / \"config.yaml\").exists()\n\n def test_put_then_get_roundtrip(self, tmp_path: Path) -> None:\n \"\"\"PUT then GET returns the persisted settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n client.put(\n \"/api/settings\",\n json={\n \"api_keys\": {\"openrouter\": \"sk-roundtrip-key\"},\n \"inference\": {\"temperature\": 0.0, \"seed\": 99},\n },\n )\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"api_keys\"][\"openrouter\"] == \"sk-roundtrip-key\"\n assert data[\"inference\"][\"seed\"] == 99\n\n def test_put_partial_update_preserves_other_fields(self, tmp_path: Path) -> None:\n \"\"\"PUT with only api_keys preserves existing inference settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n # First set inference\n client.put(\n \"/api/settings\",\n json={\"inference\": {\"seed\": 77}},\n )\n # Then update only api_keys\n client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"together\": \"tok-abc\"}},\n )\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"inference\"][\"seed\"] == 77\n assert data[\"api_keys\"][\"together\"] == \"tok-abc\"\n\n def test_get_models_returns_model_list(self) -> None:\n \"\"\"GET /api/settings/models returns available models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n assert resp.status_code == 200\n data = resp.json()\n assert isinstance(data, list)\n assert len(data) >= 1\n # Verify expected fields on the first model\n model = data[0]\n assert \"model_id\" in model\n assert \"name\" in model\n assert \"provider\" in model\n assert \"version\" in model\n assert \"license\" in model\n\n def test_get_models_contains_known_models(self) -> None:\n \"\"\"GET /api/settings/models includes the four configured models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n model_ids = {m[\"model_id\"] for m in resp.json()}\n assert \"qwen3\" in model_ids\n assert \"deepseek-v3\" in model_ids\n\n def test_test_key_empty_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with empty key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"empty\" in data[\"message\"].lower()\n\n def test_test_key_short_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with short key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"abc\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"short\" in data[\"message\"].lower()\n\n def test_test_key_real_verification(self) -> None:\n \"\"\"POST /api/settings/test-key with fake key attempts real API call.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"sk-or-v1-abcdefghijklmnop\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n # Fake key fails real verification (401, timeout, or connection error)\n assert isinstance(data[\"valid\"], bool)\n assert len(data[\"message\"]) > 0\n\n def test_put_enabled_models(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings with enabled_models persists model list.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"enabled_models\": [\"qwen3\", \"deepseek\"]},\n )\n assert resp.status_code == 200\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"enabled_models\"] == [\"qwen3\", \"deepseek\"]\n"}, "5912c90bdadd43500f58018ab068a0e832d4af75": {"t": 1785768848.5397203, "n": 6489, "h": "f76e29e753156a40", "c": "\"\"\"Tests for the settings API routes.\"\"\"\nfrom __future__ import annotations\n\nfrom pathlib import Path\nfrom unittest.mock import patch\n\nfrom fastapi.testclient import TestClient\n\n\nclass TestSettingsAPI:\n \"\"\"Test settings CRUD endpoints.\"\"\"\n\n def _client(self) -> TestClient:\n \"\"\"Create a test client for the FastAPI app.\n\n Returns:\n TestClient wired to the MetaScreener FastAPI app.\n \"\"\"\n from metascreener.api.main import create_app\n\n return TestClient(create_app())\n\n def test_get_settings_returns_defaults(self, tmp_path: Path) -> None:\n \"\"\"GET /api/settings returns default settings when no config exists.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert \"api_keys\" in data\n assert \"inference\" in data\n assert data[\"inference\"][\"temperature\"] == 0.0\n assert data[\"inference\"][\"seed\"] == 42\n\n def test_put_settings_updates_api_key(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings persists changes to disk.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"openrouter\": \"sk-test-123456789\"}},\n )\n assert resp.status_code == 200\n assert resp.json() == {\"status\": \"ok\"}\n assert (tmp_path / \"config.yaml\").exists()\n\n def test_put_then_get_roundtrip(self, tmp_path: Path) -> None:\n \"\"\"PUT then GET returns the persisted settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n client.put(\n \"/api/settings\",\n json={\n \"api_keys\": {\"openrouter\": \"sk-roundtrip-key\"},\n \"inference\": {\"temperature\": 0.0, \"seed\": 99},\n },\n )\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"api_keys\"][\"openrouter\"] == \"sk-roundtrip-key\"\n assert data[\"inference\"][\"seed\"] == 99\n\n def test_put_partial_update_preserves_other_fields(self, tmp_path: Path) -> None:\n \"\"\"PUT with only api_keys preserves existing inference settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n # First set inference\n client.put(\n \"/api/settings\",\n json={\"inference\": {\"seed\": 77}},\n )\n # Then update only api_keys\n client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"together\": \"tok-abc\"}},\n )\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"inference\"][\"seed\"] == 77\n assert data[\"api_keys\"][\"together\"] == \"tok-abc\"\n\n def test_get_models_returns_model_list(self) -> None:\n \"\"\"GET /api/settings/models returns available models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n assert resp.status_code == 200\n data = resp.json()\n assert isinstance(data, list)\n assert len(data) >= 1\n # Verify expected fields on the first model\n model = data[0]\n assert \"model_id\" in model\n assert \"name\" in model\n assert \"provider\" in model\n assert \"version\" in model\n assert \"license\" in model\n\n def test_get_models_contains_known_models(self) -> None:\n \"\"\"GET /api/settings/models includes the four configured models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n model_ids = {m[\"model_id\"] for m in resp.json()}\n assert \"qwen3\" in model_ids\n assert \"deepseek-v3\" in model_ids\n\n def test_test_key_empty_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with empty key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"empty\" in data[\"message\"].lower()\n\n def test_test_key_short_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with short key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"abc\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"short\" in data[\"message\"].lower()\n\n def test_test_key_real_verification(self) -> None:\n \"\"\"POST /api/settings/test-key with fake key attempts real API call.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"sk-or-v1-abcdefghijklmnop\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n # Fake key fails real verification (401, timeout, or connection error)\n assert isinstance(data[\"valid\"], bool)\n assert len(data[\"message\"]) > 0\n\n def test_put_enabled_models(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings with enabled_models persists model list.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"enabled_models\": [\"qwen3\", \"deepseek\"]},\n )\n assert resp.status_code == 200\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"enabled_models\"] == [\"qwen3\", \"deepseek\"]\n"}, "808c76f11ef0cc1ab06b6941f287949ec0c04c18": {"t": 1785768849.8829303, "n": 6486, "h": "9b02eb13975967c2", "c": "\"\"\"Tests for the settings API routes.\"\"\"\nfrom __future__ import annotations\n\nfrom pathlib import Path\nfrom unittest.mock import patch\n\nfrom fastapi.testclient import TestClient\n\n\nclass TestSettingsAPI:\n \"\"\"Test settings CRUD endpoints.\"\"\"\n\n def _client(self) -> TestClient:\n \"\"\"Create a test client for the FastAPI app.\n\n Returns:\n TestClient wired to the MetaScreener FastAPI app.\n \"\"\"\n from metascreener.api.main import create_app\n\n return TestClient(create_app())\n\n def test_get_settings_returns_defaults(self, tmp_path: Path) -> None:\n \"\"\"GET /api/settings returns default settings when no config exists.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert \"api_keys\" in data\n assert \"inference\" in data\n assert data[\"inference\"][\"temperature\"] == 0.0\n assert data[\"inference\"][\"seed\"] == 42\n\n def test_put_settings_updates_api_key(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings persists changes to disk.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"openrouter\": \"sk-test-123456789\"}},\n )\n assert resp.status_code == 200\n assert resp.json() == {\"status\": \"ok\"}\n assert (tmp_path / \"config.yaml\").exists()\n\n def test_put_then_get_roundtrip(self, tmp_path: Path) -> None:\n \"\"\"PUT then GET returns the persisted settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n client.put(\n \"/api/settings\",\n json={\n \"api_keys\": {\"openrouter\": \"sk-roundtrip-key\"},\n \"inference\": {\"temperature\": 0.0, \"seed\": 99},\n },\n )\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"api_keys\"][\"openrouter\"] == \"sk-roundtrip-key\"\n assert data[\"inference\"][\"seed\"] == 99\n\n def test_put_partial_update_preserves_other_fields(self, tmp_path: Path) -> None:\n \"\"\"PUT with only api_keys preserves existing inference settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n # First set inference\n client.put(\n \"/api/settings\",\n json={\"inference\": {\"seed\": 77}},\n )\n # Then update only api_keys\n client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"together\": \"tok-abc\"}},\n )\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"inference\"][\"seed\"] == 77\n assert data[\"api_keys\"][\"together\"] == \"tok-abc\"\n\n def test_get_models_returns_model_list(self) -> None:\n \"\"\"GET /api/settings/models returns available models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n assert resp.status_code == 200\n data = resp.json()\n assert isinstance(data, list)\n assert len(data) >= 1\n # Verify expected fields on the first model\n model = data[0]\n assert \"model_id\" in model\n assert \"name\" in model\n assert \"provider\" in model\n assert \"version\" in model\n assert \"license\" in model\n\n def test_get_models_contains_known_models(self) -> None:\n \"\"\"GET /api/settings/models includes the four configured models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n model_ids = {m[\"model_id\"] for m in resp.json()}\n assert \"qwen3\" in model_ids\n assert \"deepseek\" in model_ids\n\n def test_test_key_empty_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with empty key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"empty\" in data[\"message\"].lower()\n\n def test_test_key_short_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with short key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"abc\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"short\" in data[\"message\"].lower()\n\n def test_test_key_real_verification(self) -> None:\n \"\"\"POST /api/settings/test-key with fake key attempts real API call.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"sk-or-v1-abcdefghijklmnop\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n # Fake key fails real verification (401, timeout, or connection error)\n assert isinstance(data[\"valid\"], bool)\n assert len(data[\"message\"]) > 0\n\n def test_put_enabled_models(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings with enabled_models persists model list.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"enabled_models\": [\"qwen3\", \"deepseek\"]},\n )\n assert resp.status_code == 200\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"enabled_models\"] == [\"qwen3\", \"deepseek\"]\n"}, "c4e5a4435832596d01217cca8bfd524115121b07": {"t": 1785768852.2132075, "n": 6348, "h": "46c7f0a70184c248", "c": "\"\"\"Tests for the settings API routes.\"\"\"\nfrom __future__ import annotations\n\nfrom pathlib import Path\nfrom unittest.mock import patch\n\nfrom fastapi.testclient import TestClient\n\n\nclass TestSettingsAPI:\n \"\"\"Test settings CRUD endpoints.\"\"\"\n\n def _client(self) -> TestClient:\n \"\"\"Create a test client for the FastAPI app.\n\n Returns:\n TestClient wired to the MetaScreener FastAPI app.\n \"\"\"\n from metascreener.api.main import create_app\n\n return TestClient(create_app())\n\n def test_get_settings_returns_defaults(self, tmp_path: Path) -> None:\n \"\"\"GET /api/settings returns default settings when no config exists.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert \"api_keys\" in data\n assert \"inference\" in data\n assert data[\"inference\"][\"temperature\"] == 0.0\n assert data[\"inference\"][\"seed\"] == 42\n\n def test_put_settings_updates_api_key(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings persists changes to disk.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"openrouter\": \"sk-test-123456789\"}},\n )\n assert resp.status_code == 200\n assert resp.json() == {\"status\": \"ok\"}\n assert (tmp_path / \"config.yaml\").exists()\n\n def test_put_then_get_roundtrip(self, tmp_path: Path) -> None:\n \"\"\"PUT then GET returns the persisted settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n client.put(\n \"/api/settings\",\n json={\n \"api_keys\": {\"openrouter\": \"sk-roundtrip-key\"},\n \"inference\": {\"temperature\": 0.0, \"seed\": 99},\n },\n )\n resp = client.get(\"/api/settings\")\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"api_keys\"][\"openrouter\"] == \"sk-roundtrip-key\"\n assert data[\"inference\"][\"seed\"] == 99\n\n def test_put_partial_update_preserves_other_fields(self, tmp_path: Path) -> None:\n \"\"\"PUT with only api_keys preserves existing inference settings.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n # First set inference\n client.put(\n \"/api/settings\",\n json={\"inference\": {\"seed\": 77}},\n )\n # Then update only api_keys\n client.put(\n \"/api/settings\",\n json={\"api_keys\": {\"together\": \"tok-abc\"}},\n )\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"inference\"][\"seed\"] == 77\n assert data[\"api_keys\"][\"together\"] == \"tok-abc\"\n\n def test_get_models_returns_model_list(self) -> None:\n \"\"\"GET /api/settings/models returns available models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n assert resp.status_code == 200\n data = resp.json()\n assert isinstance(data, list)\n assert len(data) >= 1\n # Verify expected fields on the first model\n model = data[0]\n assert \"model_id\" in model\n assert \"name\" in model\n assert \"provider\" in model\n assert \"version\" in model\n assert \"license\" in model\n\n def test_get_models_contains_known_models(self) -> None:\n \"\"\"GET /api/settings/models includes the four configured models.\"\"\"\n client = self._client()\n resp = client.get(\"/api/settings/models\")\n model_ids = {m[\"model_id\"] for m in resp.json()}\n assert \"qwen3\" in model_ids\n assert \"deepseek\" in model_ids\n\n def test_test_key_empty_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with empty key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"empty\" in data[\"message\"].lower()\n\n def test_test_key_short_returns_invalid(self) -> None:\n \"\"\"POST /api/settings/test-key with short key returns invalid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"abc\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is False\n assert \"short\" in data[\"message\"].lower()\n\n def test_test_key_valid_format(self) -> None:\n \"\"\"POST /api/settings/test-key with plausible key returns valid.\"\"\"\n client = self._client()\n resp = client.post(\n \"/api/settings/test-key\",\n json={\"provider\": \"openrouter\", \"api_key\": \"sk-or-v1-abcdefghijklmnop\"},\n )\n assert resp.status_code == 200\n data = resp.json()\n assert data[\"valid\"] is True\n\n def test_put_enabled_models(self, tmp_path: Path) -> None:\n \"\"\"PUT /api/settings with enabled_models persists model list.\"\"\"\n with patch(\n \"metascreener.api.routes.settings._config_path\",\n return_value=tmp_path / \"config.yaml\",\n ):\n client = self._client()\n resp = client.put(\n \"/api/settings\",\n json={\"enabled_models\": [\"qwen3\", \"deepseek\"]},\n )\n assert resp.status_code == 200\n resp = client.get(\"/api/settings\")\n data = resp.json()\n assert data[\"enabled_models\"] == [\"qwen3\", \"deepseek\"]\n"}}}} |