gamemaster-design-copilot / tests /test_sources.py
vivekchakraverty's picture
Deploy CPU-first GameMaster Design Copilot
68d076e verified
Raw
History Blame Contribute Delete
1.23 kB
from pathlib import Path
import pytest
from pydantic import ValidationError
from gamemaster_copilot.sources import load_source_registry
def test_empty_registry_loads(tmp_path: Path) -> None:
registry_path = tmp_path / "sources.yaml"
registry_path.write_text("sources: []\n", encoding="utf-8")
registry = load_source_registry(registry_path)
assert registry.sources == []
assert registry.approved_ingestable_sources() == []
def test_registry_rejects_unapproved_permission(tmp_path: Path) -> None:
registry_path = tmp_path / "sources.yaml"
registry_path.write_text(
"""
sources:
- id: bad_source
title: Bad Source
path: bad.md
license: unknown
permission: copyrighted
""",
encoding="utf-8",
)
with pytest.raises(ValidationError):
load_source_registry(registry_path)
def test_registry_requires_one_location(tmp_path: Path) -> None:
registry_path = tmp_path / "sources.yaml"
registry_path.write_text(
"""
sources:
- id: missing_location
title: Missing Location
license: owned
permission: owned
""",
encoding="utf-8",
)
with pytest.raises(ValidationError):
load_source_registry(registry_path)