Skip to content

Commit e668d04

Browse files
authored
fix(tests): fix called_with issue in some tests (#42799)
fixes the easier broken test assertions reported in #42712
1 parent 52407a9 commit e668d04

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

tests/sentry/auth/test_helper.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from unittest import mock
22

3-
from django.contrib import messages
43
from django.contrib.auth.models import AnonymousUser
54
from django.test import Client, RequestFactory
65

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

167166
assert redirect.url == mock_auth.get_login_redirect.return_value
168-
assert mock_auth.get_login_redirect.called_with(self.request)
167+
mock_auth.get_login_redirect.assert_called_with(self.request)
169168

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

190189
assert redirect.url == mock_auth.get_login_redirect.return_value
191-
assert mock_auth.get_login_redirect.called_with(self.request)
190+
mock_auth.get_login_redirect.assert_called_with(self.request)
192191

193192
persisted_identity = AuthIdentity.objects.get(ident=auth_identity.ident)
194193
assert persisted_identity.data == self.identity["data"]
@@ -227,8 +226,8 @@ def test_new_identity(self, mock_messages):
227226
data=auth_identity.get_audit_log_data(),
228227
).exists()
229228

230-
assert mock_messages.add_message.called_with(
231-
self.request, messages.SUCCESS, OK_LINK_IDENTITY
229+
mock_messages.add_message.assert_called_with(
230+
self.request, mock_messages.SUCCESS, OK_LINK_IDENTITY
232231
)
233232

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

247-
assert mock_messages.add_message.called_with(
248-
self.request, messages.SUCCESS, OK_LINK_IDENTITY
246+
mock_messages.add_message.assert_called_with(
247+
self.request, mock_messages.SUCCESS, OK_LINK_IDENTITY
249248
)
250249

251250
@mock.patch("sentry.auth.helper.messages")

tests/sentry/integrations/utils/test_code_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_more_than_one_repo_match(self, logger):
226226
code_mappings = self.code_mapping_helper.generate_code_mappings(stacktraces)
227227
# The file appears in more than one repo, thus, we are unable to determine the code mapping
228228
assert code_mappings == []
229-
assert logger.warning.called_with("More than one repo matched sentry/web/urls.py")
229+
logger.warning.assert_called_with("More than one repo matched sentry/web/urls.py")
230230

231231
def test_list_file_matches_single(self):
232232
frame_filename = FrameFilename("sentry_plugins/slack/client.py")

tests/sentry/notifications/utils/test_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_end_to_end(self, notification):
2828
def test_call_task(self, mock_delay):
2929
register()(AnotherDummyNotification)
3030
async_send_notification(AnotherDummyNotification, self.organization, "some_value")
31-
assert mock_delay.called_with(
31+
mock_delay.assert_called_with(
3232
"AnotherDummyNotification",
3333
[
3434
{

0 commit comments

Comments
 (0)