MCPcopy
hub / github.com/zhayujie/CowAgent / run_stub

Function run_stub

tests/test_evolution.py:557–658  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

555# Runner (stub mode)
556# ---------------------------------------------------------------------------
557def run_stub():
558 from agent.evolution.executor import run_evolution_for_session
559 from agent.evolution import backup as backup_mod
560 from config import conf
561 # Evolution is disabled by default now; enable for the test.
562 conf()["self_evolution_enabled"] = True
563
564 passed, failed = 0, 0
565 for make in SCENARIOS:
566 sc = make()
567 ws = _setup_workspace()
568 try:
569 _point_config_at(ws)
570 # Patch channel push to capture instead of send.
571 channel = FakeChannel()
572 import agent.evolution.executor as ex
573 orig_notify = ex._notify_user
574 ex._notify_user = lambda ct, rcv, summary: channel.send(
575 type("R", (), {"content": summary})(),
576 {"receiver": rcv},
577 )
578
579 agent = FakeAgent(_make_messages(sc["turns"]))
580 bridge = FakeAgentBridge(agent, sc["scripted"], on_edit=sc["on_edit"])
581
582 evolved = run_evolution_for_session(
583 bridge, "session_test", channel_type="telegram", receiver="user_42"
584 )
585
586 ok = True
587 errs = []
588
589 if evolved != sc["expect_evolved"]:
590 ok = False
591 errs.append(f"evolved={evolved}, expected {sc['expect_evolved']}")
592
593 if sc["expect_evolved"]:
594 # memory / skill content checks
595 if "expect_memory_contains" in sc:
596 # Evolution now writes to the dated daily file, not MEMORY.md.
597 from datetime import datetime
598 daily = ws / "memory" / (datetime.now().strftime("%Y-%m-%d") + ".md")
599 mem = daily.read_text() if daily.exists() else ""
600 if sc["expect_memory_contains"] not in mem:
601 ok = False
602 errs.append("daily memory missing expected content")
603 if "expect_skill_contains" in sc:
604 sk, txt = sc["expect_skill_contains"]
605 content = (ws / "skills" / sk / "SKILL.md").read_text()
606 if txt not in content:
607 ok = False
608 errs.append("skill missing expected content")
609 if sc.get("expect_new_skill") and not _new_skill_dirs(ws):
610 ok = False
611 errs.append("expected a new skill to be created")
612 # notify happened
613 if not channel.sent:
614 ok = False

Callers 1

test_evolution.pyFile · 0.85

Calls 12

sendMethod · 0.95
confFunction · 0.90
_setup_workspaceFunction · 0.85
_point_config_atFunction · 0.85
FakeChannelClass · 0.85
FakeAgentClass · 0.85
_make_messagesFunction · 0.85
FakeAgentBridgeClass · 0.85
_new_skill_dirsFunction · 0.85
_verify_undoFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected