handoff fixes
This commit is contained in:
parent
89ddebdb60
commit
8d5e9712a6
20 changed files with 1056 additions and 141 deletions
57
backend/tests/test_handoff_mirror_policy.py
Normal file
57
backend/tests/test_handoff_mirror_policy.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
from bson import ObjectId
|
||||
|
||||
from app.services.handoff_mirror_policy import (
|
||||
GENERATED_BY_CUSTOMER,
|
||||
GENERATED_BY_HANDOFF_BRIDGE,
|
||||
GENERATED_BY_RELAY_ACK,
|
||||
MESSAGE_ORIGIN_EXTERNAL_CUSTOMER,
|
||||
MESSAGE_ORIGIN_HUMAN_OWNER,
|
||||
is_relay_acknowledgment_message,
|
||||
should_mirror_to_human,
|
||||
)
|
||||
|
||||
|
||||
def test_should_mirror_customer_inbound():
|
||||
message = {
|
||||
"message_scope": "EXTERNAL",
|
||||
"direction": "inbound",
|
||||
"generated_by": GENERATED_BY_CUSTOMER,
|
||||
"message_origin": MESSAGE_ORIGIN_EXTERNAL_CUSTOMER,
|
||||
}
|
||||
assert should_mirror_to_human(message) is True
|
||||
|
||||
|
||||
def test_should_not_mirror_handoff_bridge_outbound():
|
||||
message = {
|
||||
"message_scope": "EXTERNAL",
|
||||
"direction": "outbound",
|
||||
"generated_by": GENERATED_BY_HANDOFF_BRIDGE,
|
||||
"generated_from_handoff_message_id": ObjectId(),
|
||||
}
|
||||
assert should_mirror_to_human(message) is False
|
||||
|
||||
|
||||
def test_should_not_mirror_human_origin():
|
||||
message = {
|
||||
"message_scope": "EXTERNAL",
|
||||
"direction": "inbound",
|
||||
"message_origin": MESSAGE_ORIGIN_HUMAN_OWNER,
|
||||
}
|
||||
assert should_mirror_to_human(message) is False
|
||||
|
||||
|
||||
def test_is_relay_acknowledgment_detects_legacy_body():
|
||||
message = {
|
||||
"direction": "outbound",
|
||||
"body_text": "Sent to customer:\n\nhuman said B",
|
||||
}
|
||||
assert is_relay_acknowledgment_message(message) is True
|
||||
|
||||
|
||||
def test_is_relay_acknowledgment_detects_generated_by():
|
||||
message = {
|
||||
"direction": "outbound",
|
||||
"generated_by": GENERATED_BY_RELAY_ACK,
|
||||
"body_text": "anything",
|
||||
}
|
||||
assert is_relay_acknowledgment_message(message) is True
|
||||
Loading…
Add table
Add a link
Reference in a new issue