feat: enhance message handling with content pattern matching and update environment configuration
This commit is contained in:
@@ -53,6 +53,44 @@ def test_should_delete_message():
|
||||
)
|
||||
|
||||
|
||||
def test_message_matches_pattern_content_and_embeds():
|
||||
message = {
|
||||
"content": "This is a smoke test payload",
|
||||
"embeds": [
|
||||
{"title": "Reminder", "description": "Half-time in 5 minutes"}
|
||||
],
|
||||
}
|
||||
|
||||
assert maintenance.message_matches_pattern(message, r"smoke test")
|
||||
assert maintenance.message_matches_pattern(message, r"half-time")
|
||||
assert not maintenance.message_matches_pattern(message, r"does-not-match")
|
||||
|
||||
|
||||
def test_should_delete_message_with_content_pattern():
|
||||
ts = int(datetime(2026, 1, 1, 10, 0, 0, tzinfo=timezone.utc).timestamp())
|
||||
message = {
|
||||
"timestamp": "2026-01-01T10:00:00Z",
|
||||
"webhook_id": "w",
|
||||
"author": {"id": "a"},
|
||||
"embeds": [{"description": "This is a test notification."}],
|
||||
}
|
||||
|
||||
assert maintenance.should_delete_message(
|
||||
message,
|
||||
webhook_id="w",
|
||||
author_id="a",
|
||||
cutoff=ts,
|
||||
content_pattern=r"test notification",
|
||||
)
|
||||
assert not maintenance.should_delete_message(
|
||||
message,
|
||||
webhook_id="w",
|
||||
author_id="a",
|
||||
cutoff=ts,
|
||||
content_pattern=r"production-only",
|
||||
)
|
||||
|
||||
|
||||
def test_get_rate_limit_retry_after_header_priority():
|
||||
response = DummyResponse(
|
||||
headers={
|
||||
|
||||
Reference in New Issue
Block a user