Skip to content

Commit

Permalink
Fix test for version 2.13.0 sentry-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
spous-ovl committed Aug 14, 2024
1 parent 7ef6fcc commit 38da474
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions tests/test_extension_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ def test_sentry_sdk_installed(mocker):
"""
Check that the scope.set_tag method is called when Sentry is installed.
"""
set_tag_mock = Mock()
scope_mock = Mock()
scope_mock.set_tag = set_tag_mock

class MockedScope:
def __enter__(self):
return scope_mock

def __exit__(self, exc_type, exc_val, exc_tb):
pass

mocker.patch.object(sentry_sdk, 'configure_scope', return_value=MockedScope())
set_transaction_id(id_value)
set_tag_mock.assert_called_once_with('transaction_id', id_value)
if sentry_sdk.VERSION >= "2.12.0":
set_tag_mock = Mock()
scope_mock = Mock()
scope_mock.set_tag = set_tag_mock
mocker.patch.object(sentry_sdk, 'get_isolation_scope', return_value=scope_mock)
set_transaction_id(id_value)
set_tag_mock.assert_called_once_with('transaction_id', id_value)
else:
set_tag_mock = Mock()
scope_mock = Mock()
scope_mock.set_tag = set_tag_mock

class MockedScope:
def __enter__(self):
return scope_mock

def __exit__(self, exc_type, exc_val, exc_tb):
pass

mocker.patch.object(sentry_sdk, 'configure_scope', return_value=MockedScope())
set_transaction_id(id_value)
set_tag_mock.assert_called_once_with('transaction_id', id_value)

0 comments on commit 38da474

Please sign in to comment.