Files
memex/projects/org-skill-tech-analyst/tests/simulate_analyst.py

48 lines
1.8 KiB
Python

import os
import shutil
def simulate_perceive(project_name, projects_dir):
protocol_path = os.path.join(projects_dir, project_name, "PROTOCOL.org")
test_path = os.path.join(projects_dir, project_name, "tests", "test-suite.lisp")
if not os.path.exists(protocol_path):
return None
with open(protocol_path, 'r') as f:
content = f.read()
if "#+STATUS: SIGNED" in content and not os.path.exists(test_path):
return {"project": project_name, "protocol_path": protocol_path, "content": content}
return None
if __name__ == "__main__":
test_dir = "/tmp/analyst_test_projects"
if os.path.exists(test_dir):
shutil.rmtree(test_dir)
os.makedirs(os.path.join(test_dir, "test-project", "tests"))
proto_file = os.path.join(test_dir, "test-project", "PROTOCOL.org")
print("--- Test 1: Draft Protocol ---")
with open(proto_file, "w") as f:
f.write("#+TITLE: Test\n#+STATUS: DRAFT\n")
res = simulate_perceive("test-project", test_dir)
print(f"Result: {res}")
status1 = "PASS" if res is None else "FAIL"
print("\n--- Test 2: Signed Protocol ---")
with open(proto_file, "w") as f:
f.write("#+TITLE: Test\n#+STATUS: SIGNED\n")
res = simulate_perceive("test-project", test_dir)
print(f"Result: {res['project'] if res else None}")
status2 = "PASS" if res and res['project'] == "test-project" else "FAIL"
print("\n--- Test 3: TDD suite already exists ---")
with open(os.path.join(test_dir, "test-project", "tests", "test-suite.lisp"), "w") as f:
f.write("exists")
res = simulate_perceive("test-project", test_dir)
print(f"Result: {res}")
status3 = "PASS" if res is None else "FAIL"
print(f"\nFinal Status: {'PASS' if all(s == 'PASS' for s in [status1, status2, status3]) else 'FAIL'}")