@@ -124,21 +124,7 @@ def expected_configurations(
124
124
125
125
126
126
class ProjectStacktraceLinkTest (BaseProjectStacktraceLink ):
127
- endpoint = "sentry-api-0-project-stacktrace-link"
128
-
129
- def setUp (self ) -> None :
130
- BaseProjectStacktraceLink .setUp (self )
131
- self .code_mapping1 = self ._create_code_mapping (
132
- stack_root = "usr/src/getsentry/" ,
133
- source_root = "" ,
134
- )
135
- self .code_mapping2 = self ._create_code_mapping (
136
- stack_root = "sentry/" ,
137
- source_root = "src/sentry/" ,
138
- automatically_generated = True , # Created by the automation
139
- )
140
-
141
- self .filepath = "usr/src/getsentry/src/sentry/src/sentry/utils/safe.py"
127
+ filepath = "usr/src/getsentry/src/sentry/src/sentry/utils/safe.py"
142
128
143
129
def test_no_filepath (self ) -> None :
144
130
"""The file query search is missing"""
@@ -168,10 +154,11 @@ def test_no_configs(self) -> None:
168
154
169
155
def test_file_not_found_error (self ) -> None :
170
156
"""File matches code mapping but it cannot be found in the source repository."""
157
+ cm = self ._create_code_mapping (stack_root = "usr/src/getsentry/" , source_root = "" )
171
158
response = self .get_success_response (
172
159
self .organization .slug , self .project .slug , qs_params = {"file" : self .filepath }
173
160
)
174
- assert response .data ["config" ] == self .expected_configurations (self . code_mapping1 )
161
+ assert response .data ["config" ] == self .expected_configurations (cm )
175
162
assert not response .data ["sourceUrl" ]
176
163
assert response .data ["error" ] == "file_not_found"
177
164
assert response .data ["integrations" ] == [serialized_integration (self .integration )]
@@ -182,6 +169,8 @@ def test_file_not_found_error(self) -> None:
182
169
183
170
def test_stack_root_mismatch_error (self ) -> None :
184
171
"""Looking for a stacktrace file path that will not match any code mappings"""
172
+ # At least one code mapping to produce the stack_root_mismatch error
173
+ self ._create_code_mapping (stack_root = "usr/src/getsentry/" , source_root = "" )
185
174
response = self .get_success_response (
186
175
self .organization .slug , self .project .slug , qs_params = {"file" : "wrong/file/path" }
187
176
)
@@ -195,10 +184,11 @@ def test_config_and_source_url(self) -> None:
195
184
with patch .object (
196
185
ExampleIntegration , "get_stacktrace_link" , return_value = "https://sourceurl.com/"
197
186
):
187
+ cm = self ._create_code_mapping (stack_root = "usr/src/getsentry/" , source_root = "" )
198
188
response = self .get_success_response (
199
189
self .organization .slug , self .project .slug , qs_params = {"file" : self .filepath }
200
190
)
201
- assert response .data ["config" ] == self .expected_configurations (self . code_mapping1 )
191
+ assert response .data ["config" ] == self .expected_configurations (cm )
202
192
assert response .data ["sourceUrl" ] == "https://sourceurl.com/"
203
193
assert response .data ["integrations" ] == [serialized_integration (self .integration )]
204
194
@@ -207,6 +197,8 @@ def test_file_no_stack_root_match(self, mock_integration: MagicMock) -> None:
207
197
# Pretend that the file was not found in the repository
208
198
mock_integration .return_value = None
209
199
200
+ # At least one code mapping to produce the stack_root_mismatch error
201
+ self ._create_code_mapping (stack_root = "usr/src/getsentry/" , source_root = "" )
210
202
response = self .get_success_response (
211
203
self .organization .slug ,
212
204
self .project .slug ,
0 commit comments