File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
sentry_dynamic_sampling_lib Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 27
27
- pyflakes==2.4.0
28
28
29
29
- repo : https://github.com/pycqa/isort
30
- rev : 5.10.1
30
+ rev : 5.12.0
31
31
hooks :
32
32
- id : isort
33
33
args : ["-m=VERTICAL_HANGING_INDENT", "--combine-as", "--profile=black"]
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ def init_wrapper():
42
42
sentry_sdk : sentry_sdk_type = importlib .import_module ("sentry_sdk" )
43
43
client = sentry_sdk .Hub .current .client
44
44
45
+ if client is None :
46
+ return
47
+
45
48
if CONTROLLER_HOST :
46
49
app_key = build_app_key (client .options )
47
50
controller_endpoint = urljoin (CONTROLLER_HOST , CONTROLLER_PATH )
Original file line number Diff line number Diff line change 1
- from unittest .mock import Mock , patch
1
+ from unittest .mock import MagicMock , Mock , patch
2
2
3
3
import pytest
4
4
@@ -26,6 +26,18 @@ def test_init_wrapper_no_sentry(importlib_mock: Mock):
26
26
importlib_mock .import_module .assert_not_called ()
27
27
28
28
29
+ @patch ("sentry_dynamic_sampling_lib.importlib" )
30
+ def test_init_wrapper_no_client (importlib_mock : Mock ):
31
+ importlib_mock .util .find_spec .return_value = True
32
+ sentry_sdk = MagicMock ()
33
+ sentry_sdk .Hub .current .client = None
34
+ importlib_mock .import_module .return_value = sentry_sdk
35
+
36
+ init_wrapper ()
37
+ importlib_mock .util .find_spec .assert_called_once_with ("sentry_sdk" )
38
+ importlib_mock .import_module .assert_called_once_with ("sentry_sdk" )
39
+
40
+
29
41
@patch ("sentry_dynamic_sampling_lib.TraceSampler" )
30
42
@patch ("sentry_dynamic_sampling_lib.importlib" )
31
43
def test_init_wrapper_no_controller (importlib_mock : Mock , trace_sampler : Mock ):
You can’t perform that action at this time.
0 commit comments