personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: convert identity-hydrate tests to in-process

Replaces six per-test python subprocess invocations
(`subprocess.run([sys.executable, "-c", "from think.tools.sol import
app; app()"])`) with direct calls to `_hydrate()`. monkeypatch sets
SOLSTONE_JOURNAL via the journal_path fixture; SOL_SKIP_SUPERVISOR_
CHECK is no longer needed because the unit-level helper bypasses
require_solstone() entirely.

Same six assertions, same behavior coverage. 6 tests run in 0.07s
instead of multiple seconds of cold-import-per-subprocess. No more
risk of the 15s global timeout biting a busy box.

+24 -49
+24 -49
tests/test_sol_call_identity_hydrate.py
··· 2 2 # Copyright (c) 2026 sol pbc 3 3 4 4 import json 5 - import os 6 - import subprocess 7 - import sys 8 5 9 6 import pytest 10 7 11 - from think.tools.sol import _SPECIES_PREAMBLE 8 + from think.tools.sol import _SPECIES_PREAMBLE, _hydrate 12 9 13 10 14 11 @pytest.fixture 15 - def journal_path(tmp_path): 12 + def journal_path(tmp_path, monkeypatch): 16 13 config_dir = tmp_path / "config" 17 14 config_dir.mkdir() 18 15 (config_dir / "journal.json").write_text(json.dumps({})) 16 + monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path)) 19 17 return tmp_path 20 18 21 19 22 - def _run_identity_hydrate(journal_path): 23 - env = os.environ.copy() 24 - env.update( 25 - { 26 - "SOLSTONE_JOURNAL": str(journal_path), 27 - "SOL_SKIP_SUPERVISOR_CHECK": "1", 28 - } 29 - ) 30 - return subprocess.run( 31 - [sys.executable, "-c", "from think.tools.sol import app; app()"], 32 - capture_output=True, 33 - text=True, 34 - check=False, 35 - env=env, 36 - ) 37 - 38 - 39 20 def test_identity_hydrate_reads_all_sections(journal_path): 40 21 identity_dir = journal_path / "identity" 41 22 identity_dir.mkdir() ··· 44 25 (identity_dir / "agency.md").write_text("agency body") 45 26 (identity_dir / "awareness.md").write_text("awareness body") 46 27 47 - result = _run_identity_hydrate(journal_path) 28 + output = _hydrate() 48 29 49 - assert result.returncode == 0 50 30 expected = ["# self", "# partner", "# agency", "# awareness"] 51 - positions = [result.stdout.index(marker) for marker in expected] 31 + positions = [output.index(marker) for marker in expected] 52 32 assert positions == sorted(positions) 53 - assert "self body" in result.stdout 54 - assert "partner body" in result.stdout 55 - assert "agency body" in result.stdout 56 - assert "awareness body" in result.stdout 33 + assert "self body" in output 34 + assert "partner body" in output 35 + assert "agency body" in output 36 + assert "awareness body" in output 57 37 58 38 59 39 def test_identity_hydrate_marks_missing_sections(journal_path): ··· 63 43 (identity_dir / "partner.md").write_text("partner body") 64 44 (identity_dir / "awareness.md").write_text("awareness body") 65 45 66 - result = _run_identity_hydrate(journal_path) 46 + output = _hydrate() 67 47 68 - assert result.returncode == 0 69 - assert "# agency\n\n(not present)\n" in result.stdout 48 + assert "# agency\n\n(not present)\n" in output 70 49 71 50 72 51 def test_identity_hydrate_handles_empty_identity_directory(journal_path): 73 - result = _run_identity_hydrate(journal_path) 52 + output = _hydrate() 74 53 75 - assert result.returncode == 0 76 54 for stem in ("self", "partner", "agency", "awareness"): 77 - assert f"# {stem}\n\n(not present)\n" in result.stdout 55 + assert f"# {stem}\n\n(not present)\n" in output 78 56 79 57 80 58 def test_identity_hydrate_starts_with_species_preamble(journal_path): ··· 85 63 (identity_dir / "agency.md").write_text("agency body") 86 64 (identity_dir / "awareness.md").write_text("awareness body") 87 65 88 - result = _run_identity_hydrate(journal_path) 66 + output = _hydrate() 89 67 90 - assert result.returncode == 0 91 - assert result.stdout.startswith("# species\n\n") 92 - assert _SPECIES_PREAMBLE in result.stdout 68 + assert output.startswith("# species\n\n") 69 + assert _SPECIES_PREAMBLE in output 93 70 expected = ["# species", "# self", "# partner", "# agency", "# awareness"] 94 - positions = [result.stdout.index(marker) for marker in expected] 71 + positions = [output.index(marker) for marker in expected] 95 72 assert positions == sorted(positions) 96 73 97 74 ··· 103 80 (identity_dir / "agency.md").write_text("agency body") 104 81 (identity_dir / "awareness.md").write_text("awareness body") 105 82 106 - result = _run_identity_hydrate(journal_path) 83 + output = _hydrate() 107 84 108 - assert result.returncode == 0 109 - assert result.stdout.splitlines().count("# self") == 1 110 - assert "# self\n\nself body" in result.stdout 85 + assert output.splitlines().count("# self") == 1 86 + assert "# self\n\nself body" in output 111 87 112 88 113 89 def test_identity_hydrate_preserves_non_matching_heading(journal_path): ··· 118 94 (identity_dir / "agency.md").write_text("agency body") 119 95 (identity_dir / "awareness.md").write_text("awareness body") 120 96 121 - result = _run_identity_hydrate(journal_path) 97 + output = _hydrate() 122 98 123 - assert result.returncode == 0 124 - assert "# My Custom Heading" in result.stdout 125 - assert result.stdout.splitlines().count("# self") == 1 126 - assert "self body" in result.stdout 99 + assert "# My Custom Heading" in output 100 + assert output.splitlines().count("# self") == 1 101 + assert "self body" in output