Files
phelex 88ac95dd19 Integrate Antirion admin with FastAPI and htmx
Add the shared document API, constructor and expert editors, isolated preview, and fragment catalog metadata with typed block IDs.

Include design references, specification 001, QA scripts, project guidance, and cached Docker dependency installation. Leave example sites for a separate commit.
2026-11-12 21:55:36 +03:00

33 lines
1.2 KiB
Python

import datetime as dt
import shutil
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
EXAMPLE = ROOT / "examples" / "studio-site"
NOW = dt.datetime(2026, 11, 7, 12, 0, 0, tzinfo=dt.timezone.utc)
class SiteTestCase(unittest.TestCase):
"""Каждый тест получает свежую копию примера во временном каталоге."""
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
self.addCleanup(self._tmp.cleanup)
self.tmp = Path(self._tmp.name)
self.site = self.tmp / "site"
shutil.copytree(EXAMPLE, self.site, ignore=shutil.ignore_patterns('.engine'))
self.out = self.tmp / "dist"
def edit(self, rel: str, old: str, new: str) -> None:
path = self.site / rel
text = path.read_text(encoding="utf-8")
assert old in text, f"{old!r} не найден в {rel}"
path.write_text(text.replace(old, new), encoding="utf-8")
def write(self, rel: str, text: str) -> None:
path = self.site / rel
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")