Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
import fcntl
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from pageswiki_cli_test import pageswiki_cli
|
|
|
|
|
|
class DRGuardTest(unittest.TestCase):
|
|
def test_standby_rejected_before_database_open(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
(root / "pages.db").write_bytes(b"not a database; must not be opened")
|
|
(root / "dr-node.json").write_text(json.dumps({"version": 1, "role": "standby"}))
|
|
with patch.dict(os.environ, {"PAGESWIKI_DATA_DIR": directory, "PAGESWIKI_DB": str(root / "pages.db"), "PAGESWIKI_DOCUMENTS_DIR": str(root / "documents")}):
|
|
with self.assertRaisesRegex(pageswiki_cli.CLIError, "standby"):
|
|
pageswiki_cli.PagesWikiCLI()
|
|
|
|
def test_offline_maintenance_lock_blocks_cli(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
(root / "pages.db").write_bytes(b"not a database")
|
|
with (root / ".pageswiki-instance.lock").open("wb") as lock:
|
|
fcntl.flock(lock.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
with patch.dict(os.environ, {"PAGESWIKI_DATA_DIR": directory, "PAGESWIKI_DB": str(root / "pages.db")}):
|
|
with self.assertRaisesRegex(pageswiki_cli.CLIError, "maintenance guard"):
|
|
pageswiki_cli.PagesWikiCLI()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|