linux observer
at main 39 lines 1.2 kB view raw
1# SPDX-License-Identifier: AGPL-3.0-only 2# Copyright (c) 2026 sol pbc 3 4"""Tests for the observer module — segment lifecycle and local cache.""" 5 6from pathlib import Path 7 8from solstone_linux.config import Config 9from solstone_linux.recovery import write_segment_metadata 10 11 12class TestSegmentMetadata: 13 """Test .metadata file creation for recovery.""" 14 15 def test_writes_metadata(self, tmp_path: Path): 16 import json 17 18 seg_dir = tmp_path / "test.incomplete" 19 seg_dir.mkdir() 20 write_segment_metadata(seg_dir, 1712160000.0) 21 22 meta_path = seg_dir / ".metadata" 23 assert meta_path.exists() 24 25 data = json.loads(meta_path.read_text()) 26 assert data["start_timestamp"] == 1712160000.0 27 28 29class TestSegmentDirStructure: 30 """Test that config directories follow the expected structure.""" 31 32 def test_captures_dir_path(self, tmp_path: Path): 33 config = Config(base_dir=tmp_path) 34 assert str(config.captures_dir).endswith("captures") 35 36 def test_restore_token_path(self, tmp_path: Path): 37 config = Config(base_dir=tmp_path) 38 assert str(config.restore_token_path).endswith("restore_token") 39 assert "config" in str(config.restore_token_path)