Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch and verify an expected UserWarning in the test suite #8041

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions tests/test_events/test_events_integration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import contextlib
import json
import os
from datetime import datetime
from unittest import SkipTest, mock

import boto3
import pytest

from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
Expand Down Expand Up @@ -110,16 +112,23 @@ def test_send_to_sqs_fifo_queue():

# when
event_time = datetime(2021, 1, 1, 12, 23, 34)
client_events.put_events(
Entries=[
{
"Time": event_time,
"Source": "source",
"DetailType": "type",
"Detail": json.dumps({"key": "value"}),
}
]
# Catch and validate a UserWarning when running locally.
context = (
pytest.warns(UserWarning, match="you must enable content-based deduplication")
if not settings.TEST_SERVER_MODE
else contextlib.nullcontext()
)
with context:
client_events.put_events(
Entries=[
{
"Time": event_time,
"Source": "source",
"DetailType": "type",
"Detail": json.dumps({"key": "value"}),
}
]
)

# then
response = client_sqs.receive_message(
Expand Down
Loading