feat: initial discord meeting bot
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
from helpers import (
|
||||
build_transcript_block,
|
||||
chunk_message,
|
||||
command_channel_error,
|
||||
summarize_error,
|
||||
)
|
||||
|
||||
|
||||
def test_chunk_message_splits_long_text_under_limit():
|
||||
text = "A" * 4500
|
||||
chunks = chunk_message(text, limit=1900)
|
||||
assert len(chunks) == 3
|
||||
assert all(len(c) <= 1900 for c in chunks)
|
||||
assert "".join(chunks) == text
|
||||
|
||||
|
||||
def test_chunk_message_keeps_short_text_single_chunk():
|
||||
text = "hello world"
|
||||
assert chunk_message(text, limit=1900) == [text]
|
||||
|
||||
|
||||
def test_summarize_error_prefers_json_message():
|
||||
body = {"error": {"message": "bad request"}}
|
||||
assert summarize_error(body, fallback="x") == "bad request"
|
||||
|
||||
|
||||
def test_summarize_error_falls_back_to_string():
|
||||
assert summarize_error({"unexpected": True}, fallback="fallback") == "fallback"
|
||||
|
||||
|
||||
def test_build_transcript_block_labels_transcript():
|
||||
block = build_transcript_block("Chris", "Discussed deadlines")
|
||||
assert block == "[Chris]\nDiscussed deadlines"
|
||||
|
||||
|
||||
def test_command_channel_error_allows_matching_channel():
|
||||
assert command_channel_error(current_channel_id=123, allowed_channel_id=123) is None
|
||||
|
||||
|
||||
def test_command_channel_error_blocks_when_not_configured():
|
||||
assert command_channel_error(current_channel_id=123, allowed_channel_id=None) == (
|
||||
"⚠️ This bot doesn't have a command channel yet. Use `/set_output` first."
|
||||
)
|
||||
|
||||
|
||||
def test_command_channel_error_blocks_wrong_channel():
|
||||
assert command_channel_error(current_channel_id=123, allowed_channel_id=456) == (
|
||||
"⚠️ This command only works in <#456>."
|
||||
)
|
||||
Reference in New Issue
Block a user