repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | """Regression tests for TripleStore default data-directory handling.""" |
| #2 | |
| #3 | import os |
| #4 | import subprocess |
| #5 | import sys |
| #6 | import textwrap |
| #7 | from pathlib import Path |
| #8 | |
| #9 | |
| #10 | def _run_python(script: str, *, home: Path, data_dir: Path) -> subprocess.CompletedProcess: |
| #11 | env = os.environ.copy() |
| #12 | env["HOME"] = str(home) |
| #13 | env["MNEMOSYNE_DATA_DIR"] = str(data_dir) |
| #14 | env.pop("PYTHONHOME", None) |
| #15 | |
| #16 | return subprocess.run( |
| #17 | [sys.executable, "-c", textwrap.dedent(script)], |
| #18 | text=True, |
| #19 | capture_output=True, |
| #20 | env=env, |
| #21 | check=False, |
| #22 | ) |
| #23 | |
| #24 | |
| #25 | def test_triplestore_default_db_uses_mnemosyne_data_dir(tmp_path): |
| #26 | """TripleStore() should keep triples.db beside the configured memory DBs.""" |
| #27 | home = tmp_path / "home" |
| #28 | data_dir = tmp_path / "configured-data" |
| #29 | |
| #30 | result = _run_python( |
| #31 | """ |
| #32 | from mnemosyne.core.triples import TripleStore |
| #33 | |
| #34 | store = TripleStore() |
| #35 | print(store.db_path) |
| #36 | """, |
| #37 | home=home, |
| #38 | data_dir=data_dir, |
| #39 | ) |
| #40 | |
| #41 | assert result.returncode == 0, result.stderr |
| #42 | assert Path(result.stdout.strip()) == data_dir / "triples.db" |
| #43 | assert (data_dir / "triples.db").exists() |
| #44 | assert not (home / ".hermes" / "mnemosyne" / "data" / "triples.db").exists() |
| #45 | |
| #46 | |
| #47 | def test_triplestore_copies_legacy_db_into_mnemosyne_data_dir(tmp_path): |
| #48 | """Existing misplaced triples should be copied into the configured data dir.""" |
| #49 | home = tmp_path / "home" |
| #50 | data_dir = tmp_path / "configured-data" |
| #51 | legacy_db = home / ".hermes" / "mnemosyne" / "data" / "triples.db" |
| #52 | |
| #53 | seed = _run_python( |
| #54 | """ |
| #55 | from pathlib import Path |
| #56 | from mnemosyne.core.triples import TripleStore |
| #57 | |
| #58 | legacy_db = Path.home() / ".hermes" / "mnemosyne" / "data" / "triples.db" |
| #59 | store = TripleStore(db_path=legacy_db) |
| #60 | store.add( |
| #61 | "legacy-subject", |
| #62 | "legacy-predicate", |
| #63 | "legacy-object", |
| #64 | valid_from="2026-05-08", |
| #65 | ) |
| #66 | print(legacy_db) |
| #67 | """, |
| #68 | home=home, |
| #69 | data_dir=data_dir, |
| #70 | ) |
| #71 | assert seed.returncode == 0, seed.stderr |
| #72 | assert legacy_db.exists() |
| #73 | assert not (data_dir / "triples.db").exists() |
| #74 | |
| #75 | result = _run_python( |
| #76 | """ |
| #77 | from mnemosyne.core.triples import TripleStore |
| #78 | |
| #79 | store = TripleStore() |
| #80 | print(store.db_path) |
| #81 | print(store.query(subject="legacy-subject")[0]["object"]) |
| #82 | """, |
| #83 | home=home, |
| #84 | data_dir=data_dir, |
| #85 | ) |
| #86 | |
| #87 | assert result.returncode == 0, result.stderr |
| #88 | assert result.stdout.splitlines() == [ |
| #89 | str(data_dir / "triples.db"), |
| #90 | "legacy-object", |
| #91 | ] |
| #92 | assert legacy_db.exists() |
| #93 | assert (data_dir / "triples.db").exists() |
| #94 |