personal memory agent
at main 59 lines 1.5 kB view raw
1# SPDX-License-Identifier: AGPL-3.0-only 2# Copyright (c) 2026 sol pbc 3 4"""Self-contained fixtures for observer app tests. 5 6These fixtures are fully standalone and only depend on pytest builtins. 7No shared dependencies from the root conftest.py are required. 8""" 9 10from __future__ import annotations 11 12import json 13 14import pytest 15 16 17@pytest.fixture 18def observer_env(tmp_path, monkeypatch): 19 """Create a temporary journal for observer app testing. 20 21 Returns a factory function that sets up the environment and returns 22 the Flask test client along with the journal path. 23 """ 24 25 def _create(): 26 journal = tmp_path / "journal" 27 journal.mkdir() 28 29 config_dir = journal / "config" 30 config_dir.mkdir(parents=True, exist_ok=True) 31 config_file = config_dir / "journal.json" 32 config_file.write_text( 33 json.dumps( 34 { 35 "convey": {"trust_localhost": True}, 36 "setup": {"completed_at": 1700000000000}, 37 }, 38 indent=2, 39 ) 40 ) 41 42 # Set environment 43 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(journal)) 44 45 # Create Flask test client 46 from convey import create_app 47 48 app = create_app(journal=str(journal)) 49 client = app.test_client() 50 51 class Env: 52 def __init__(self): 53 self.journal = journal 54 self.client = client 55 self.app = app 56 57 return Env() 58 59 return _create