Files
auto-reverse/tests/test_repl.py

33 lines
924 B
Python

from auto_reverse.models import CapturedFlow
from auto_reverse.repl import Repl
from auto_reverse.store import FlowStore, ScopeFilter
class FakeAgent:
def run_turn(self, msg):
return f"agent saw: {msg}"
def _store():
s = FlowStore(ScopeFilter(target_hosts={"ex.com"}))
s.ingest(CapturedFlow(
method="GET", host="ex.com", path="/api/users", query={}, req_headers={},
req_body=None, status=200, resp_headers={}, resp_body=None, timestamp=0.0,
))
return s
def test_quit_returns_none():
repl = Repl(FakeAgent(), _store(), "openapi.yaml")
assert repl.handle("/quit") is None
def test_flows_lists_endpoints():
repl = Repl(FakeAgent(), _store(), "openapi.yaml")
assert "/api/users" in repl.handle("/flows")
def test_plain_text_goes_to_agent():
repl = Repl(FakeAgent(), _store(), "openapi.yaml")
assert repl.handle("map users") == "agent saw: map users"