diff --git a/tests/live/test_live.py b/tests/live/test_live.py index 0cc6b8c..9116c67 100644 --- a/tests/live/test_live.py +++ b/tests/live/test_live.py @@ -436,6 +436,7 @@ def _alert_ok(a): def test_conversation_layer_on_real_data(frontline): """Every conversation helper against the login's own data. Compares types, counts, masking and links only.""" conv = frontline.conversations + steps = {} # step name -> a count or "ran": printed at the end, never any content me, teams = conv.me(), conv.teams() assert me.user_id and me.lines is None and all(t.location_id and t.name for t in teams) @@ -444,6 +445,7 @@ def test_conversation_layer_on_real_data(frontline): for b in briefs: _brief_ok(b) assert b.key_points == [] and b.tasks == [] # list results carry the summary fields only + steps["teams"], steps["calls"] = len(teams), len(briefs) if not briefs: pytest.skip("no calls in the last 7 days for this login") whens = [b.when for b in briefs if b.when] @@ -458,6 +460,11 @@ def test_conversation_layer_on_real_data(frontline): assert isinstance(transcript, list) and all(set(seg) <= {"time", "speaker", "name", "text"} for seg in transcript) link = conv.recording_link(first.id) assert link is None or (link.url.startswith("https://") and link.url not in repr(link)) + steps["brief"] = "ran" + steps["brief key points"], steps["brief tasks"] = len(first.key_points), len(first.tasks) + steps["brief topics"], steps["brief alerts"] = len(first.topics), len(first.alerts) + steps["transcript segments"] = len(transcript) + steps["recording link"] = "none" if link is None else "ran" # caller history needs a full number: read one with the lower-level helper and keep it in memory only raw = frontline.intelligence.search_calls(date_from=NOW - timedelta(days=7), limit=10).items @@ -467,6 +474,7 @@ def test_conversation_layer_on_real_data(frontline): assert len(history) <= 3 for b in history: _brief_ok(b) + steps["caller history"] = len(history) if number else "no full number found" alerts = conv.alerts(since=NOW - timedelta(days=14), limit=10) assert len(alerts) <= 10 @@ -480,11 +488,14 @@ def test_conversation_layer_on_real_data(frontline): _brief_ok(one.call) ref = conv.reference(one) assert (ref.kind, ref.id, ref.link) == ("alert", one.id, one.link) + steps["alerts"] = len(alerts) + steps["alert by id"] = ("ran, with call" if one.call is not None else "ran, no call") if alerts else "no alerts" with pytest.raises(ic.InvalidRequestError): conv.alerts(status="open") # the API has no status filter tasks = conv.open_tasks() assert len(tasks) <= 200 and all(isinstance(t, ic.conversations.TaskBrief) and t.id for t in tasks) + steps["open tasks"] = len(tasks) if teams: view = conv.team_view(teams[0], since=NOW - timedelta(days=2)) @@ -493,18 +504,26 @@ def test_conversation_layer_on_real_data(frontline): _brief_ok(b) for a in view.alerts: _alert_ok(a) + steps["team view"] = f"ran, {len(view.briefs)} briefs, {len(view.alerts)} alerts" + else: + steps["team view"] = "no teams" try: topics = conv.topics(since=NOW - timedelta(days=7)) except ic.ApiError as exc: # the login has no Insights Hub access assert exc.status in (403, 404) + steps["topics"] = f"refused ({exc.status})" else: assert all(isinstance(v, int) for v in topics.calls.values()) assert all({"name", "call_count"} <= set(t) for t in topics.topics) + steps["topics"] = f"ran, {len(topics.topics)} topics, {len(topics.rising)} rising" for bad in ({"since": NOW - timedelta(days=40)}, {"limit": 201}, {"day": NOW.date(), "since": NOW}): with pytest.raises(ic.InvalidRequestError): conv.calls(**bad) + steps["refused inputs"] = 4 + # Counts and step names only. Run pytest with -s to see the line. + print("\nsteps: " + ", ".join(f"{k}: {v}" for k, v in steps.items())) def test_frontline_calls(frontline):