Skip to content

fix(feedback): fix patching flakes with test_openai.py #95577

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

Merged
merged 1 commit into from
Jul 15, 2025
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
30 changes: 12 additions & 18 deletions tests/sentry/feedback/test_create_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ def test_create_feedback_spam_detection_produce_to_kafka(
mock_produce_occurrence_to_kafka,
input_message,
expected_result,
monkeypatch,
feature_flag,
):
with Feature({"organizations:user-feedback-spam-ingest": feature_flag}):
Expand Down Expand Up @@ -491,11 +490,10 @@ def test_create_feedback_spam_detection_produce_to_kafka(
mock_openai = Mock()
mock_openai().chat.completions.create = create_dummy_openai_response

monkeypatch.setattr("sentry.llm.providers.openai.OpenAI", mock_openai)

create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)
with patch("sentry.llm.providers.openai.OpenAI", mock_openai):
create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)

# Check if the 'is_spam' evidence in the Kafka message matches the expected result
is_spam_evidence = [
Expand Down Expand Up @@ -526,7 +524,6 @@ def test_create_feedback_spam_detection_produce_to_kafka(
def test_create_feedback_spam_detection_project_option_false(
default_project,
mock_produce_occurrence_to_kafka,
monkeypatch,
):
default_project.update_option("sentry:feedback_ai_spam_detection", False)

Expand Down Expand Up @@ -567,11 +564,10 @@ def test_create_feedback_spam_detection_project_option_false(
mock_openai = Mock()
mock_openai().chat.completions.create = create_dummy_openai_response

monkeypatch.setattr("sentry.llm.providers.openai.OpenAI", mock_openai)

create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)
with patch("sentry.llm.providers.openai.OpenAI", mock_openai):
create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)

# Check if the 'is_spam' evidence in the Kafka message matches the expected result
is_spam_evidence = [
Expand All @@ -588,7 +584,6 @@ def test_create_feedback_spam_detection_project_option_false(
@django_db_all
def test_create_feedback_spam_detection_set_status_ignored(
default_project,
monkeypatch,
):
with Feature(
{
Expand Down Expand Up @@ -632,11 +627,10 @@ def test_create_feedback_spam_detection_set_status_ignored(
mock_openai = Mock()
mock_openai().chat.completions.create = create_dummy_openai_response

monkeypatch.setattr("sentry.llm.providers.openai.OpenAI", mock_openai)

create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)
with patch("sentry.llm.providers.openai.OpenAI", mock_openai):
create_feedback_issue(
event, default_project.id, FeedbackCreationSource.NEW_FEEDBACK_ENVELOPE
)

group = Group.objects.get()
assert group.status == GroupStatus.IGNORED
Expand Down
Loading