51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from unittest.mock import AsyncMock, MagicMock
|
|
import pytest
|
|
import discord
|
|
from chorus_bot.cogs.manual_share import ManualShareCog
|
|
from chorus_bot.ping import parse_ping_embed
|
|
|
|
|
|
class _FakeConfig:
|
|
inbox_channel_id = 111
|
|
triage_role_id = 222
|
|
|
|
|
|
def _make_message(*, channel_name, content="hello", author_bot=False, channel_id=999):
|
|
message = MagicMock(spec=discord.Message)
|
|
message.author.bot = author_bot
|
|
message.channel.id = channel_id
|
|
message.channel.name = channel_name
|
|
message.content = content
|
|
message.created_at = __import__("datetime").datetime(2026, 7, 13, 7, 0, 0)
|
|
return message
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_leads_found_channel_forwards_with_outbound_direction():
|
|
bot = MagicMock()
|
|
inbox = AsyncMock()
|
|
bot.get_channel.return_value = inbox
|
|
cog = ManualShareCog(bot, _FakeConfig())
|
|
|
|
message = _make_message(channel_name="leads-found", content="Neighbor posting about book giveaway")
|
|
await cog.on_message(message)
|
|
|
|
sent_embed = inbox.send.call_args.kwargs["embed"]
|
|
parsed = parse_ping_embed(sent_embed)
|
|
assert parsed["direction"] == "outbound"
|
|
assert parsed["modality"] == "lead_found"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_existing_modality_channel_still_forwards_with_inbound_direction():
|
|
bot = MagicMock()
|
|
inbox = AsyncMock()
|
|
bot.get_channel.return_value = inbox
|
|
cog = ManualShareCog(bot, _FakeConfig())
|
|
|
|
message = _make_message(channel_name="voice", content="call about donation")
|
|
await cog.on_message(message)
|
|
|
|
sent_embed = inbox.send.call_args.kwargs["embed"]
|
|
parsed = parse_ping_embed(sent_embed)
|
|
assert parsed["direction"] == "inbound"
|