fix: P1 Quick-Reply Dedup — 3x-Bug + UX-Text-Anpassung
- outbound_gate.py: separates _quick_reply_sent Dict fuer Trigger-Raeume (nicht an _in_flight gebunden), mark_quick_reply_sent/quick_reply_already_sent - adapter.py: zentraler _maybe_send_quick_reply Helper mit Dedup + kontext- abhaengigem Text (same-room vs cross-room) - send() und send_clarify() rufen beide den Helper statt duplizierter Logik - Tests: 3 Gate-Tests (6.1-6.3) + 3 Integration-Tests (Dedup, Same-Room-Text, Cross-Room-Text) - Diff: 268 Zeilen (<300 F4-Limit)
This commit is contained in:
@@ -287,55 +287,41 @@ def test_outbound_gate_stats_defaults():
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@pytest.mark.outbound_gate
|
||||
@pytest.mark.asyncio
|
||||
async def test_mark_quick_reply_sent_first_call_returns_true():
|
||||
def test_mark_quick_reply_sent_first_call_returns_true():
|
||||
"""6.1: mark_quick_reply_sent returns True beim ersten Aufruf."""
|
||||
gate = OutboundGate()
|
||||
room = "ROOM_QR_TEST_1"
|
||||
token = "token-qr-1"
|
||||
|
||||
await gate.try_acquire(room, token)
|
||||
result = gate.mark_quick_reply_sent(room)
|
||||
assert result is True, "First mark_quick_reply_sent should return True"
|
||||
|
||||
gate.release(room, token)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# 6.2: mark_quick_reply_sent returns False on second call (idempotent)
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@pytest.mark.outbound_gate
|
||||
@pytest.mark.asyncio
|
||||
async def test_mark_quick_reply_sent_second_call_returns_false():
|
||||
def test_mark_quick_reply_sent_second_call_returns_false():
|
||||
"""6.2: mark_quick_reply_sent returns False beim zweiten Aufruf (idempotent)."""
|
||||
gate = OutboundGate()
|
||||
room = "ROOM_QR_TEST_2"
|
||||
token = "token-qr-2"
|
||||
|
||||
await gate.try_acquire(room, token)
|
||||
first = gate.mark_quick_reply_sent(room)
|
||||
assert first is True
|
||||
|
||||
second = gate.mark_quick_reply_sent(room)
|
||||
assert second is False, "Second mark_quick_reply_sent should return False (idempotent)"
|
||||
|
||||
gate.release(room, token)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# 6.3: quick_reply_already_sent returns correct before/after mark
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@pytest.mark.outbound_gate
|
||||
@pytest.mark.asyncio
|
||||
async def test_quick_reply_already_sent_before_and_after():
|
||||
def test_quick_reply_already_sent_before_and_after():
|
||||
"""6.3: quick_reply_already_sent returns korrekt vor/nach mark."""
|
||||
gate = OutboundGate()
|
||||
room = "ROOM_QR_TEST_3"
|
||||
token = "token-qr-3"
|
||||
|
||||
await gate.try_acquire(room, token)
|
||||
|
||||
# Before mark: should be False
|
||||
assert gate.quick_reply_already_sent(room) is False
|
||||
@@ -344,5 +330,3 @@ async def test_quick_reply_already_sent_before_and_after():
|
||||
|
||||
# After mark: should be True
|
||||
assert gate.quick_reply_already_sent(room) is True
|
||||
|
||||
gate.release(room, token)
|
||||
|
||||
Reference in New Issue
Block a user