Private
Public Access
artifacts
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
"""Phase 2 verification: flat_config returns ProjectContext."""
|
||||
from src.project_manager import flat_config
|
||||
from src.models import ProjectContext, ProjectMeta, ProjectOutput, ProjectFiles, ProjectScreenshots, ProjectDiscussion
|
||||
|
||||
# Test 1: empty dict input
|
||||
ctx = flat_config({})
|
||||
assert isinstance(ctx, ProjectContext)
|
||||
assert isinstance(ctx.project, ProjectMeta)
|
||||
assert isinstance(ctx.output, ProjectOutput)
|
||||
assert isinstance(ctx.files, ProjectFiles)
|
||||
assert isinstance(ctx.screenshots, ProjectScreenshots)
|
||||
assert isinstance(ctx.discussion, ProjectDiscussion)
|
||||
assert ctx.project.name == ""
|
||||
assert ctx.output.output_dir == ""
|
||||
assert ctx.files.paths == ()
|
||||
assert ctx.screenshots.base_dir == "."
|
||||
assert ctx.screenshots.paths == ()
|
||||
assert ctx.discussion.roles == ()
|
||||
assert ctx.discussion.history == ()
|
||||
print("Test 1 OK: empty dict -> ProjectContext with zero defaults")
|
||||
|
||||
# Test 2: full dict input
|
||||
proj = {
|
||||
"project": {"name": "test-proj", "summary_only": True, "execution_mode": "fast"},
|
||||
"output": {"namespace": "ns1", "output_dir": "/tmp/out"},
|
||||
"files": {"base_dir": "/src", "paths": ["a.py", "b.py"]},
|
||||
"screenshots": {"base_dir": "/scr", "paths": ["s1.png"]},
|
||||
"context_presets": {"p1": {"name": "p1"}},
|
||||
"discussion": {
|
||||
"active": "main",
|
||||
"roles": ["User", "AI"],
|
||||
"discussions": {"main": {"history": ["msg1", "msg2"]}},
|
||||
},
|
||||
}
|
||||
ctx = flat_config(proj, disc_name="main")
|
||||
assert ctx.project.name == "test-proj"
|
||||
assert ctx.project.summary_only is True
|
||||
assert ctx.project.execution_mode == "fast"
|
||||
assert ctx.output.namespace == "ns1"
|
||||
assert ctx.output.output_dir == "/tmp/out"
|
||||
assert ctx.files.base_dir == "/src"
|
||||
assert ctx.files.paths == ("a.py", "b.py")
|
||||
assert ctx.screenshots.base_dir == "/scr"
|
||||
assert ctx.screenshots.paths == ("s1.png",)
|
||||
assert ctx.discussion.roles == ("User", "AI")
|
||||
assert ctx.discussion.history == ("msg1", "msg2")
|
||||
print("Test 2 OK: full dict input -> correct dataclass fields")
|
||||
|
||||
# Test 3: dict-compat methods
|
||||
assert ctx.get("files") == {"base_dir": "/src", "paths": ["a.py", "b.py"]}
|
||||
assert ctx["output"] == {"namespace": "ns1", "output_dir": "/tmp/out"}
|
||||
assert ctx.get("missing", "default") == "default"
|
||||
print("Test 3 OK: dict-compat __getitem__ / get work")
|
||||
|
||||
# Test 4: to_dict() round-trip
|
||||
d = ctx.to_dict()
|
||||
assert d["project"]["name"] == "test-proj"
|
||||
assert d["output"]["output_dir"] == "/tmp/out"
|
||||
assert d["files"]["paths"] == ["a.py", "b.py"]
|
||||
assert d["discussion"]["roles"] == ["User", "AI"]
|
||||
assert d["context_presets"] == {"p1": {"name": "p1"}}
|
||||
print("Test 4 OK: to_dict() round-trip preserves data")
|
||||
|
||||
# Test 5: EMPTY_PROJECT_CONTEXT sentinel
|
||||
from src.models import EMPTY_PROJECT_CONTEXT
|
||||
assert isinstance(EMPTY_PROJECT_CONTEXT, ProjectContext)
|
||||
print("Test 5 OK: EMPTY_PROJECT_CONTEXT sentinel exists")
|
||||
|
||||
print("\nAll 5 Phase 2 verification tests PASS.")
|
||||
Reference in New Issue
Block a user