|
1 | 1 | """Tests for palinode.migration.openclaw — OpenClaw MEMORY.md import.""" |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
4 | | -import os |
| 4 | +import subprocess |
5 | 5 | import textwrap |
6 | 6 | from datetime import UTC |
7 | 7 | from pathlib import Path |
8 | 8 | from unittest.mock import patch |
9 | 9 |
|
10 | 10 | import pytest |
| 11 | +import yaml as _yaml |
11 | 12 |
|
12 | 13 | from palinode.migration.openclaw import ( |
13 | 14 | _detect_type, |
@@ -49,12 +50,23 @@ def memory_md_file(tmp_path: Path) -> Path: |
49 | 50 |
|
50 | 51 | @pytest.fixture() |
51 | 52 | def fake_memory_dir(tmp_path: Path) -> Path: |
| 53 | + |
52 | 54 | mem = tmp_path / "palinode" |
53 | 55 | mem.mkdir() |
| 56 | + |
54 | 57 | # Minimal git repo so the git commit call doesn't crash |
55 | | - os.system(f"git init -q {mem} 2>/dev/null") |
56 | | - os.system(f"git -C {mem} config user.email 'test@test.com' 2>/dev/null") |
57 | | - os.system(f"git -C {mem} config user.name 'Test' 2>/dev/null") |
| 58 | + def run_git(args): |
| 59 | + subprocess.run( |
| 60 | + ["git"] + args, |
| 61 | + stdout=subprocess.DEVNULL, |
| 62 | + stderr=subprocess.DEVNULL, |
| 63 | + check=True |
| 64 | + ) |
| 65 | + |
| 66 | + run_git(["init","-q",str(mem)]) |
| 67 | + run_git(["-C",str(mem),"config","user.email","test@test.com"]) |
| 68 | + run_git(["-C", str(mem), "config", "user.name", "Test"]) |
| 69 | + |
58 | 70 | return mem |
59 | 71 |
|
60 | 72 |
|
@@ -212,7 +224,6 @@ def test_migration_creates_log_file( |
212 | 224 | def test_migration_frontmatter_fields( |
213 | 225 | memory_md_file: Path, fake_memory_dir: Path |
214 | 226 | ) -> None: |
215 | | - import yaml as _yaml |
216 | 227 |
|
217 | 228 | with patch("palinode.migration.openclaw.config") as mock_cfg: |
218 | 229 | mock_cfg.memory_dir = str(fake_memory_dir) |
|
0 commit comments