forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_conversation_processing_deterministic.py
More file actions
121 lines (108 loc) · 4.93 KB
/
Copy pathtest_conversation_processing_deterministic.py
File metadata and controls
121 lines (108 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"""Deterministic conversation-processing seam coverage."""
from fakes.firestore import seed_action_item, seed_conversation, seed_memory
def test_reprocess_route_persists_deterministic_processing_result(client, auth_headers, monkeypatch):
"""The reprocess route should persist and return deterministic processing output.
This intentionally fakes the provider-heavy processing function at the route seam.
It still exercises real auth, route validation, model serialization, Firestore read/write,
and downstream action-item queryability.
"""
conv_id = "deterministic-processing-001"
conv_data = {
"id": conv_id,
"created_at": "2025-01-15T12:00:00Z",
"started_at": "2025-01-15T12:00:00Z",
"finished_at": "2025-01-15T12:05:00Z",
"source": "omi",
"language": "en",
"structured": {
"title": "",
"overview": "",
"emoji": "🧠",
"category": "other",
"action_items": [],
"events": [],
},
"transcript_segments": [
{
"id": "seg-1",
"text": "Remember to ship the hermetic harness follow-up.",
"speaker": "SPEAKER_00",
"is_user": True,
"start": 0.0,
"end": 2.0,
}
],
"discarded": False,
"status": "completed",
"is_locked": False,
"data_protection_level": "standard",
}
seed_conversation("123", conv_data)
def fake_process_conversation(uid, language_code, conversation, **kwargs):
import database.conversations as conversations_db
structured = conversation.structured.model_dump() if hasattr(conversation.structured, "model_dump") else {}
structured.update(
{
"title": "Hermetic Harness Follow-up",
"overview": "David asked to expand backend hermetic e2e coverage.",
"emoji": "🧪",
"category": "work",
"action_items": [
{
"description": "Ship the hermetic harness follow-up",
"completed": False,
"conversation_id": conversation.id,
}
],
}
)
update = {"structured": structured}
conversations_db.update_conversation(uid, conversation.id, update)
seed_action_item(
uid,
{
"id": "ai-deterministic-processing",
"description": "Ship the hermetic harness follow-up",
"completed": False,
"created_at": "2025-01-15T12:05:00Z",
"updated_at": "2025-01-15T12:05:00Z",
"conversation_id": conversation.id,
},
)
seed_memory(
uid,
{
"id": "mem-deterministic-processing",
"content": "David prefers hermetic backend coverage before broad product e2e claims.",
"category": "system",
"visibility": "public",
"tags": ["e2e", "coverage"],
"created_at": "2025-01-15T12:05:00Z",
"updated_at": "2025-01-15T12:05:00Z",
"conversation_id": conversation.id,
"reviewed": True,
},
)
refreshed = conversations_db.get_conversation(uid, conversation.id)
from utils.conversations.factory import deserialize_conversation
return deserialize_conversation(refreshed)
import routers.conversations as conversations_router
monkeypatch.setattr(conversations_router, "process_conversation", fake_process_conversation)
resp = client.post(f"/v1/conversations/{conv_id}/reprocess", headers=auth_headers)
assert resp.status_code == 200, resp.text
body = resp.json()
assert body["id"] == conv_id
assert body["structured"]["title"] == "Hermetic Harness Follow-up"
assert body["structured"]["overview"] == "David asked to expand backend hermetic e2e coverage."
assert body["structured"]["action_items"][0]["description"] == "Ship the hermetic harness follow-up"
persisted = client.get(f"/v1/conversations/{conv_id}", headers=auth_headers)
assert persisted.status_code == 200, persisted.text
assert persisted.json()["structured"]["title"] == "Hermetic Harness Follow-up"
action_items = client.get("/v1/action-items", headers=auth_headers)
assert action_items.status_code == 200, action_items.text
descriptions = [item["description"] for item in action_items.json().get("action_items", [])]
assert "Ship the hermetic harness follow-up" in descriptions
memories = client.get("/v3/memories", headers=auth_headers)
assert memories.status_code == 200, memories.text
memory_contents = [memory["content"] for memory in memories.json()]
assert "David prefers hermetic backend coverage before broad product e2e claims." in memory_contents