|
2 | 2 | import uuid |
3 | 3 |
|
4 | 4 | import sentry_sdk |
5 | | -from sentry_sdk.crons import capture_checkin |
6 | | - |
7 | 5 | from sentry_sdk import Hub, configure_scope, set_level |
| 6 | +from sentry_sdk.crons import capture_checkin |
8 | 7 |
|
9 | 8 | try: |
10 | 9 | from unittest import mock # python 3.3 and above |
@@ -39,95 +38,95 @@ def test_decorator(sentry_init): |
39 | 38 |
|
40 | 39 | with mock.patch( |
41 | 40 | "sentry_sdk.crons.decorator.capture_checkin" |
42 | | - ) as fake_capture_checking: |
| 41 | + ) as fake_capture_checkin: |
43 | 42 | result = _hello_world("Grace") |
44 | 43 | assert result == "Hello, Grace" |
45 | 44 |
|
46 | 45 | # Check for initial checkin |
47 | | - fake_capture_checking.assert_has_calls( |
| 46 | + fake_capture_checkin.assert_has_calls( |
48 | 47 | [ |
49 | 48 | mock.call(monitor_slug="abc123", status="in_progress"), |
50 | 49 | ] |
51 | 50 | ) |
52 | 51 |
|
53 | 52 | # Check for final checkin |
54 | | - assert fake_capture_checking.call_args[1]["monitor_slug"] == "abc123" |
55 | | - assert fake_capture_checking.call_args[1]["status"] == "ok" |
56 | | - assert fake_capture_checking.call_args[1]["duration"] |
57 | | - assert fake_capture_checking.call_args[1]["check_in_id"] |
| 53 | + assert fake_capture_checkin.call_args[1]["monitor_slug"] == "abc123" |
| 54 | + assert fake_capture_checkin.call_args[1]["status"] == "ok" |
| 55 | + assert fake_capture_checkin.call_args[1]["duration"] |
| 56 | + assert fake_capture_checkin.call_args[1]["check_in_id"] |
58 | 57 |
|
59 | 58 |
|
60 | 59 | def test_decorator_error(sentry_init): |
61 | 60 | sentry_init() |
62 | 61 |
|
63 | 62 | with mock.patch( |
64 | 63 | "sentry_sdk.crons.decorator.capture_checkin" |
65 | | - ) as fake_capture_checking: |
| 64 | + ) as fake_capture_checkin: |
66 | 65 | with pytest.raises(ZeroDivisionError): |
67 | 66 | result = _break_world("Grace") |
68 | 67 |
|
69 | 68 | assert "result" not in locals() |
70 | 69 |
|
71 | 70 | # Check for initial checkin |
72 | | - fake_capture_checking.assert_has_calls( |
| 71 | + fake_capture_checkin.assert_has_calls( |
73 | 72 | [ |
74 | 73 | mock.call(monitor_slug="def456", status="in_progress"), |
75 | 74 | ] |
76 | 75 | ) |
77 | 76 |
|
78 | 77 | # Check for final checkin |
79 | | - assert fake_capture_checking.call_args[1]["monitor_slug"] == "def456" |
80 | | - assert fake_capture_checking.call_args[1]["status"] == "error" |
81 | | - assert fake_capture_checking.call_args[1]["duration"] |
82 | | - assert fake_capture_checking.call_args[1]["check_in_id"] |
| 78 | + assert fake_capture_checkin.call_args[1]["monitor_slug"] == "def456" |
| 79 | + assert fake_capture_checkin.call_args[1]["status"] == "error" |
| 80 | + assert fake_capture_checkin.call_args[1]["duration"] |
| 81 | + assert fake_capture_checkin.call_args[1]["check_in_id"] |
83 | 82 |
|
84 | 83 |
|
85 | 84 | def test_contextmanager(sentry_init): |
86 | 85 | sentry_init() |
87 | 86 |
|
88 | 87 | with mock.patch( |
89 | 88 | "sentry_sdk.crons.decorator.capture_checkin" |
90 | | - ) as fake_capture_checking: |
| 89 | + ) as fake_capture_checkin: |
91 | 90 | result = _hello_world_contextmanager("Grace") |
92 | 91 | assert result == "Hello, Grace" |
93 | 92 |
|
94 | 93 | # Check for initial checkin |
95 | | - fake_capture_checking.assert_has_calls( |
| 94 | + fake_capture_checkin.assert_has_calls( |
96 | 95 | [ |
97 | 96 | mock.call(monitor_slug="abc123", status="in_progress"), |
98 | 97 | ] |
99 | 98 | ) |
100 | 99 |
|
101 | 100 | # Check for final checkin |
102 | | - assert fake_capture_checking.call_args[1]["monitor_slug"] == "abc123" |
103 | | - assert fake_capture_checking.call_args[1]["status"] == "ok" |
104 | | - assert fake_capture_checking.call_args[1]["duration"] |
105 | | - assert fake_capture_checking.call_args[1]["check_in_id"] |
| 101 | + assert fake_capture_checkin.call_args[1]["monitor_slug"] == "abc123" |
| 102 | + assert fake_capture_checkin.call_args[1]["status"] == "ok" |
| 103 | + assert fake_capture_checkin.call_args[1]["duration"] |
| 104 | + assert fake_capture_checkin.call_args[1]["check_in_id"] |
106 | 105 |
|
107 | 106 |
|
108 | 107 | def test_contextmanager_error(sentry_init): |
109 | 108 | sentry_init() |
110 | 109 |
|
111 | 110 | with mock.patch( |
112 | 111 | "sentry_sdk.crons.decorator.capture_checkin" |
113 | | - ) as fake_capture_checking: |
| 112 | + ) as fake_capture_checkin: |
114 | 113 | with pytest.raises(ZeroDivisionError): |
115 | 114 | result = _break_world_contextmanager("Grace") |
116 | 115 |
|
117 | 116 | assert "result" not in locals() |
118 | 117 |
|
119 | 118 | # Check for initial checkin |
120 | | - fake_capture_checking.assert_has_calls( |
| 119 | + fake_capture_checkin.assert_has_calls( |
121 | 120 | [ |
122 | 121 | mock.call(monitor_slug="def456", status="in_progress"), |
123 | 122 | ] |
124 | 123 | ) |
125 | 124 |
|
126 | 125 | # Check for final checkin |
127 | | - assert fake_capture_checking.call_args[1]["monitor_slug"] == "def456" |
128 | | - assert fake_capture_checking.call_args[1]["status"] == "error" |
129 | | - assert fake_capture_checking.call_args[1]["duration"] |
130 | | - assert fake_capture_checking.call_args[1]["check_in_id"] |
| 126 | + assert fake_capture_checkin.call_args[1]["monitor_slug"] == "def456" |
| 127 | + assert fake_capture_checkin.call_args[1]["status"] == "error" |
| 128 | + assert fake_capture_checkin.call_args[1]["duration"] |
| 129 | + assert fake_capture_checkin.call_args[1]["check_in_id"] |
131 | 130 |
|
132 | 131 |
|
133 | 132 | def test_capture_checkin_simple(sentry_init): |
|
0 commit comments