Skip to content

fix(tests): fix called_with issue in some tests #42799

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
Jan 5, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions tests/sentry/auth/test_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from unittest import mock

from django.contrib import messages
from django.contrib.auth.models import AnonymousUser
from django.test import Client, RequestFactory

Expand Down Expand Up @@ -165,7 +164,7 @@ def test_simple(self, mock_auth):
redirect = self.handler.handle_existing_identity(self.state, auth_identity)

assert redirect.url == mock_auth.get_login_redirect.return_value
assert mock_auth.get_login_redirect.called_with(self.request)
mock_auth.get_login_redirect.assert_called_with(self.request)

persisted_identity = AuthIdentity.objects.get(ident=auth_identity.ident)
assert persisted_identity.data == self.identity["data"]
Expand All @@ -188,7 +187,7 @@ def test_no_invite_members_flag(self, mock_auth):
redirect = self.handler.handle_existing_identity(self.state, auth_identity)

assert redirect.url == mock_auth.get_login_redirect.return_value
assert mock_auth.get_login_redirect.called_with(self.request)
mock_auth.get_login_redirect.assert_called_with(self.request)

persisted_identity = AuthIdentity.objects.get(ident=auth_identity.ident)
assert persisted_identity.data == self.identity["data"]
Expand Down Expand Up @@ -227,8 +226,8 @@ def test_new_identity(self, mock_messages):
data=auth_identity.get_audit_log_data(),
).exists()

assert mock_messages.add_message.called_with(
self.request, messages.SUCCESS, OK_LINK_IDENTITY
mock_messages.add_message.assert_called_with(
self.request, mock_messages.SUCCESS, OK_LINK_IDENTITY
)

@mock.patch("sentry.auth.helper.messages")
Expand All @@ -244,8 +243,8 @@ def test_new_identity_with_existing_om(self, mock_messages):
assert getattr(persisted_om.flags, "sso:linked")
assert not getattr(persisted_om.flags, "sso:invalid")

assert mock_messages.add_message.called_with(
self.request, messages.SUCCESS, OK_LINK_IDENTITY
mock_messages.add_message.assert_called_with(
self.request, mock_messages.SUCCESS, OK_LINK_IDENTITY
)

@mock.patch("sentry.auth.helper.messages")
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/integrations/utils/test_code_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_more_than_one_repo_match(self, logger):
code_mappings = self.code_mapping_helper.generate_code_mappings(stacktraces)
# The file appears in more than one repo, thus, we are unable to determine the code mapping
assert code_mappings == []
assert logger.warning.called_with("More than one repo matched sentry/web/urls.py")
logger.warning.assert_called_with("More than one repo matched sentry/web/urls.py")

def test_list_file_matches_single(self):
frame_filename = FrameFilename("sentry_plugins/slack/client.py")
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/notifications/utils/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_end_to_end(self, notification):
def test_call_task(self, mock_delay):
register()(AnotherDummyNotification)
async_send_notification(AnotherDummyNotification, self.organization, "some_value")
assert mock_delay.called_with(
mock_delay.assert_called_with(
"AnotherDummyNotification",
[
{
Expand Down