Fix CAD Factory dashboard on Windows

This commit is contained in:
gagushin committed 2026-11-21 21:02:18 +04:00
1 parent a6e63ae91d
commit 449418d00f
2 files changed
+71 -11

No files matched your search

+12 -2
View File
@@ -24,8 +24,13 @@ class DashboardTest(unittest.TestCase):
self.changes.mkdir()
body = "# CF-001 — Посадочное место\n- **Текущее состояние:** `проверка`\n"
card = self.changes / "CF-001.md"
card.write_text(body, encoding="utf-8")
(self.changes / "foreign.md").symlink_to(card)
card.write_bytes(body.encode("utf-8"))
try:
(self.changes / "foreign.md").symlink_to(card)
except OSError as exc:
if getattr(exc, "winerror", None) != 1314:
raise
(self.changes / "foreign.md").mkdir()
(self.changes / "bad.md").write_bytes(b"\xff")
(self.changes / "large.md").write_bytes(b" " * (256 * 1024 + 1))
result = read_cards(self.root)
@@ -98,6 +103,8 @@ class DashboardTest(unittest.TestCase):
self.assertEqual(json.load(response), {"state": "disabled", "agents": []})
def test_http_routes_do_not_serve_files_or_accept_foreign_hosts(self):
self.changes.mkdir()
(self.changes / "CF-001.md").write_text("# CF-001\n", encoding="utf-8")
with ThreadingHTTPServer(("127.0.0.1", 0), Handler) as server:
server.root = self.root
server.activity = False
@@ -106,6 +113,9 @@ class DashboardTest(unittest.TestCase):
self.addCleanup(thread.join)
self.addCleanup(server.shutdown)
url = f"http://127.0.0.1:{server.server_port}"
with urlopen(url + "/api/cards", timeout=2) as response:
card, = json.load(response)["cards"]
self.assertEqual(card["id"], "CF-001")
with urlopen(url + "/api/activity", timeout=2) as response:
self.assertEqual(json.load(response), {"state": "disabled", "agents": []})
for request, expected in [