"""Phase 2 — Priority 5: MK-only gossip graph scenario.""" import os import sys os.environ.setdefault("CEPHEUS_CLOUD", "1") BACKEND_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) FR = os.path.join(BACKEND_DIR, "Face_Recognition") for p in (BACKEND_DIR, FR): if p not in sys.path: sys.path.insert(0, p) import gossip_bridge # noqa: E402 def test_mk_alone_produces_zero_edges_one_node(): """ User scenario: MK live on one feed; Urvi/Vidit not detected → no false edges. """ gossip_bridge.clear_graph() gossip_bridge.clear_tracking_meta() gossip_bridge.register_enrolled_roster(["MK", "Urvi", "Vidit"]) gossip_bridge.set_root_person("MK") gossip_bridge.start_tracking() gossip_bridge.on_detections( "cam-01", ["MK"], [(100, 100, 200, 200)], frame_width=640, ) data = gossip_bridge.get_gossip_json("MK") links = data.get("links", []) nodes = data.get("nodes", []) node_names = {n.get("name") for n in nodes} assert len(links) == 0, f"Expected zero edges, got {links}" assert "MK" in node_names assert "Urvi" not in node_names or not any( l.get("source") == "Urvi" or l.get("target") == "Urvi" for l in links ) assert "Vidit" not in node_names or not any( l.get("source") == "Vidit" or l.get("target") == "Vidit" for l in links ) assert len([n for n in nodes if n.get("name") == "MK"]) == 1 def test_two_person_proximity_creates_one_edge(): gossip_bridge.clear_graph() gossip_bridge.register_enrolled_roster(["MK", "Urvi"]) gossip_bridge.set_root_person("MK") gossip_bridge.start_tracking() gossip_bridge.on_detections( "cam-01", ["MK", "Urvi"], [(100, 100, 200, 200), (110, 110, 210, 210)], frame_width=640, ) data = gossip_bridge.get_gossip_json("MK") assert len(data.get("links", [])) >= 1