test(stream): move full-fallback-resend threading test to thread routing suite

The Telegram final-delivery suite is the wrong home and its delete
assertion duplicates test_stream_consumer.py. Keep only the new
behaviour: a full resend threads its first chunk to the originating
message; later chunks stay unthreaded.
This commit is contained in:
kshitijk4poor
2026-09-24 21:25:49 +05:30
committed by kshitij
parent 8d959f965c
commit fd78affe38
2 changed files with 24 additions and 22 deletions

View File

@@ -172,3 +172,27 @@ class TestFeishuFallbackThreadRouting:
f"Expected receive_id_type='thread_id', got '{receive_id_type}'"
)
class TestFallbackResendThreading:
"""#103068: a full fallback resend replaces the preview, so it must land in
the originating thread; tail continuations keep their unthreaded delivery."""
@pytest.mark.asyncio
async def test_full_fallback_resend_threads_first_chunk_only(self):
adapter = _make_adapter(max_length=700)
adapter.send.side_effect = [
SimpleNamespace(success=True, message_id=f"full_{i}") for i in range(10)
]
consumer = GatewayStreamConsumer(adapter, "chat_123", initial_reply_to_id="om_user_1")
consumer._message_id = "om_preview"
consumer._last_sent_text = "truncated snapshot"
consumer._already_sent = True
consumer._fallback_final_send = True
final = " ".join(["word"] * 400) # not prefixed by the snapshot -> full resend
await consumer._send_fallback_final(final)
calls = adapter.send.await_args_list
assert len(calls) > 1
assert calls[0].kwargs["reply_to"] == "om_user_1"
assert all("reply_to" not in c.kwargs for c in calls[1:])

View File

@@ -149,28 +149,6 @@ async def test_complete_preview_survives_long_flood_fallback_failure(monkeypatch
assert consumer.delivered_final_matches("Final answer") is True
@pytest.mark.asyncio
async def test_full_fallback_resend_threads_and_deletes_truncated_preview():
"""When the visible prefix is not a prefix of the final (Feishu post vs
cleaned text), fallback resends the whole answer. Thread it to the user
message and delete the truncated edit bubble (#103068)."""
adapter = _adapter()
adapter.send.return_value = SendResult(success=True, message_id="full-1")
consumer = GatewayStreamConsumer(
adapter, "chat-1", initial_reply_to_id="user-1",
)
consumer._message_id = "preview-1"
consumer._last_sent_text = "truncated snapshot"
consumer._already_sent = True
consumer._fallback_final_send = True
await consumer._send_fallback_final("full completed answer that does not start with the snapshot")
assert adapter.send.await_args.kwargs["reply_to"] == "user-1"
adapter.delete_message.assert_awaited()
@pytest.mark.asyncio
async def test_telegram_long_flood_result_keeps_retry_after():
"""The real adapter contract preserves the server delay for consumers."""