fix: stabilize Polygon config loading and sync
This commit is contained in:
@@ -180,3 +180,45 @@ class TestFileRoundtrip:
|
||||
assert len(loaded["cfsParams"]) == 2
|
||||
finally:
|
||||
os.unlink(fname)
|
||||
|
||||
|
||||
class TestGenerationSync:
|
||||
"""The CLI output directory should match its source after a clean run."""
|
||||
|
||||
def test_main_removes_yaml_missing_from_source(self, tmp_path, monkeypatch, dummy_yaml):
|
||||
source_dir = tmp_path / "source"
|
||||
output_dir = tmp_path / "output"
|
||||
source_dir.mkdir()
|
||||
output_dir.mkdir()
|
||||
with open(source_dir / "1_dummy.yaml", "w", encoding="utf-8") as source_file:
|
||||
yaml.safe_dump(dummy_yaml, source_file, allow_unicode=True)
|
||||
(output_dir / "27_obsolete.yaml").write_text("old: true\n", encoding="utf-8")
|
||||
(output_dir / "keep.txt").write_text("not YAML\n", encoding="utf-8")
|
||||
|
||||
monkeypatch.setattr(
|
||||
sys,
|
||||
"argv",
|
||||
["from_stands.py", str(source_dir), str(output_dir)],
|
||||
)
|
||||
from_stands.main()
|
||||
|
||||
assert (output_dir / "1_dummy.yaml").is_file()
|
||||
assert not (output_dir / "27_obsolete.yaml").exists()
|
||||
assert (output_dir / "keep.txt").is_file()
|
||||
|
||||
def test_main_keeps_existing_yaml_when_conversion_fails(self, tmp_path, monkeypatch):
|
||||
source_dir = tmp_path / "source"
|
||||
output_dir = tmp_path / "output"
|
||||
source_dir.mkdir()
|
||||
output_dir.mkdir()
|
||||
(source_dir / "broken.yaml").write_text("broken: [", encoding="utf-8")
|
||||
(output_dir / "27_obsolete.yaml").write_text("old: true\n", encoding="utf-8")
|
||||
|
||||
monkeypatch.setattr(
|
||||
sys,
|
||||
"argv",
|
||||
["from_stands.py", str(source_dir), str(output_dir)],
|
||||
)
|
||||
from_stands.main()
|
||||
|
||||
assert (output_dir / "27_obsolete.yaml").is_file()
|
||||
|
||||
Reference in New Issue
Block a user