Skip to content

Commit e3bba0f

Browse files
committed
Fix tests and missed refactor of function name
1 parent 349618d commit e3bba0f

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

tests/sentry/issues/auto_source_code_config/test_process_event.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def create_event(self, frames: Sequence[Mapping[str, str | bool]], platform: str
7171
# XXX: In the future fix store_event to return the correct type
7272
return cast(GroupEvent, self.store_event(data=test_data, project_id=self.project.id))
7373

74-
def _process_and_assert_code_mapping(
74+
def _process_and_assert_configuration_changes(
7575
self,
7676
*, # Force keyword arguments
7777
repo_trees: Mapping[str, Sequence[str]],
@@ -127,7 +127,7 @@ def _process_and_assert_code_mapping(
127127
# Returning this is useful to inspect hash changes
128128
return event
129129

130-
def _process_and_assert_no_code_mapping(
130+
def _process_and_assert_no_configuration_changes(
131131
self,
132132
*, # Force keyword arguments
133133
repo_trees: Mapping[str, Sequence[str]],
@@ -212,7 +212,9 @@ class TestGenericBehaviour(BaseDeriveCodeMappings):
212212

213213
def test_skips_not_supported_platforms(self) -> None:
214214
with patch(f"{CODE_ROOT}.utils.get_platform_config", return_value={}):
215-
self._process_and_assert_no_code_mapping(repo_trees={}, frames=[{}], platform="other")
215+
self._process_and_assert_no_configuration_changes(
216+
repo_trees={}, frames=[{}], platform="other"
217+
)
216218

217219
def test_handle_existing_code_mapping(self) -> None:
218220
with assume_test_silo_mode_of(OrganizationIntegration):
@@ -252,7 +254,7 @@ def test_dry_run_platform(self) -> None:
252254
patch(f"{CODE_ROOT}.utils.PlatformConfig.is_dry_run_platform", return_value=True),
253255
):
254256
# No code mapping will be stored, however, we get what would have been created
255-
code_mappings, _ = self._process_and_assert_no_code_mapping(
257+
code_mappings, _ = self._process_and_assert_no_configuration_changes(
256258
repo_trees={REPO1: [file_in_repo]},
257259
frames=[self.frame(frame_filename, True)],
258260
platform=platform,
@@ -272,14 +274,14 @@ def test_extension_is_not_included(self) -> None:
272274
patch(f"{REPO_TREES_CODE}.get_supported_extensions", return_value=[]),
273275
):
274276
# No extensions are supported, thus, we can't generate a code mapping
275-
self._process_and_assert_no_code_mapping(
277+
self._process_and_assert_no_configuration_changes(
276278
repo_trees={REPO1: [file_in_repo]},
277279
frames=[self.frame(frame_filename, True)],
278280
platform=platform,
279281
)
280282

281283
with patch(f"{REPO_TREES_CODE}.get_supported_extensions", return_value=["tbd"]):
282-
self._process_and_assert_code_mapping(
284+
self._process_and_assert_configuration_changes(
283285
repo_trees={REPO1: [file_in_repo]},
284286
frames=[self.frame(frame_filename, True)],
285287
platform=platform,
@@ -298,7 +300,7 @@ def test_multiple_calls(self) -> None:
298300
patch(f"{CODE_ROOT}.utils.get_platform_config", return_value={}),
299301
patch(f"{CODE_ROOT}.utils.PlatformConfig.is_supported", return_value=True),
300302
):
301-
self._process_and_assert_code_mapping(
303+
self._process_and_assert_configuration_changes(
302304
repo_trees=repo_trees,
303305
frames=[self.frame("foo/bar.py", True)],
304306
platform=platform,
@@ -308,7 +310,7 @@ def test_multiple_calls(self) -> None:
308310
expected_num_code_mappings=1,
309311
)
310312
# Processing the same stacktrace again should not create anything new
311-
self._process_and_assert_code_mapping(
313+
self._process_and_assert_configuration_changes(
312314
repo_trees=repo_trees,
313315
frames=[self.frame("foo/bar.py", True)],
314316
platform=platform,
@@ -318,7 +320,7 @@ def test_multiple_calls(self) -> None:
318320
expected_num_code_mappings=1,
319321
)
320322
# New code mapping in the same repository
321-
self._process_and_assert_code_mapping(
323+
self._process_and_assert_configuration_changes(
322324
repo_trees=repo_trees,
323325
frames=[self.frame("app/main.py", True)],
324326
platform=platform,
@@ -328,7 +330,7 @@ def test_multiple_calls(self) -> None:
328330
expected_num_code_mappings=2, # New code mapping
329331
)
330332
# New code mapping in a different repository
331-
self._process_and_assert_code_mapping(
333+
self._process_and_assert_configuration_changes(
332334
repo_trees=repo_trees,
333335
frames=[self.frame("baz/qux.py", True)],
334336
platform=platform,
@@ -356,7 +358,7 @@ def test_backslash_filename_simple(self) -> None:
356358
# The lack of a \ after the drive letter in the third frame signals that
357359
# this is a relative path. This may be unlikely to occur in practice,
358360
# but worth testing nonetheless.
359-
self._process_and_assert_code_mapping(
361+
self._process_and_assert_configuration_changes(
360362
repo_trees={REPO1: ["sentry/mouse.py"]},
361363
frames=[self.frame("\\sentry\\mouse.py", True)],
362364
platform=self.platform,
@@ -365,7 +367,7 @@ def test_backslash_filename_simple(self) -> None:
365367
)
366368

367369
def test_backslash_drive_letter_filename_simple(self) -> None:
368-
self._process_and_assert_code_mapping(
370+
self._process_and_assert_configuration_changes(
369371
repo_trees={REPO1: ["sentry/tasks.py"]},
370372
frames=[self.frame("C:sentry\\tasks.py", True)],
371373
platform=self.platform,
@@ -374,7 +376,7 @@ def test_backslash_drive_letter_filename_simple(self) -> None:
374376
)
375377

376378
def test_backslash_drive_letter_filename_monoRepoAndBranch(self) -> None:
377-
self._process_and_assert_code_mapping(
379+
self._process_and_assert_configuration_changes(
378380
repo_trees={REPO1: ["sentry/tasks.py"]},
379381
frames=[self.frame("C:sentry\\tasks.py", True)],
380382
platform=self.platform,
@@ -383,7 +385,7 @@ def test_backslash_drive_letter_filename_monoRepoAndBranch(self) -> None:
383385
)
384386

385387
def test_backslash_drive_letter_filename_abs_path(self) -> None:
386-
self._process_and_assert_code_mapping(
388+
self._process_and_assert_configuration_changes(
387389
repo_trees={REPO1: ["sentry/models/release.py"]},
388390
frames=[self.frame("D:\\Users\\code\\sentry\\models\\release.py", True)],
389391
platform=self.platform,
@@ -397,7 +399,7 @@ class TestJavascriptDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
397399

398400
def test_auto_source_code_config_starts_with_period_slash(self) -> None:
399401
# ./app/utils/handle.tsx -> app/utils/handle.tsx -> static/app/utils/handle.tsx
400-
self._process_and_assert_code_mapping(
402+
self._process_and_assert_configuration_changes(
401403
repo_trees={REPO1: ["static/app/utils/handle.tsx"]},
402404
frames=[self.frame("./app/utils/handle.tsx", True)],
403405
platform=self.platform,
@@ -406,7 +408,7 @@ def test_auto_source_code_config_starts_with_period_slash(self) -> None:
406408
)
407409

408410
def test_auto_source_code_config_starts_with_period_slash_no_containing_directory(self) -> None:
409-
self._process_and_assert_code_mapping(
411+
self._process_and_assert_configuration_changes(
410412
repo_trees={REPO1: ["app/utils/handle.tsx"]},
411413
frames=[self.frame("./app/utils/handle.tsx", True)],
412414
platform=self.platform,
@@ -415,7 +417,7 @@ def test_auto_source_code_config_starts_with_period_slash_no_containing_director
415417
)
416418

417419
def test_auto_source_code_config_one_to_one_match(self) -> None:
418-
self._process_and_assert_code_mapping(
420+
self._process_and_assert_configuration_changes(
419421
repo_trees={REPO1: ["some/path/Test.tsx"]},
420422
frames=[self.frame("some/path/Test.tsx", True)],
421423
platform=self.platform,
@@ -428,7 +430,7 @@ class TestRubyDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
428430
platform = "ruby"
429431

430432
def test_auto_source_code_config_rb(self) -> None:
431-
self._process_and_assert_code_mapping(
433+
self._process_and_assert_configuration_changes(
432434
repo_trees={REPO1: ["some/path/test.rb"]},
433435
frames=[self.frame("some/path/test.rb", True)],
434436
platform=self.platform,
@@ -437,7 +439,7 @@ def test_auto_source_code_config_rb(self) -> None:
437439
)
438440

439441
def test_auto_source_code_config_rake(self) -> None:
440-
self._process_and_assert_code_mapping(
442+
self._process_and_assert_configuration_changes(
441443
repo_trees={REPO1: ["lib/tasks/crontask.rake"]},
442444
frames=[self.frame("lib/tasks/crontask.rake", True)],
443445
platform=self.platform,
@@ -451,7 +453,7 @@ class TestNodeDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
451453

452454
def test_auto_source_code_config_starts_with_app(self) -> None:
453455
# It can handle app:// urls
454-
self._process_and_assert_code_mapping(
456+
self._process_and_assert_configuration_changes(
455457
repo_trees={REPO1: ["utils/errors.js"]},
456458
frames=[self.frame("app:///utils/errors.js", True)],
457459
platform=self.platform,
@@ -460,7 +462,7 @@ def test_auto_source_code_config_starts_with_app(self) -> None:
460462
)
461463

462464
def test_auto_source_code_config_starts_with_app_complex(self) -> None:
463-
self._process_and_assert_code_mapping(
465+
self._process_and_assert_configuration_changes(
464466
repo_trees={REPO1: ["sentry/utils/errors.js"]},
465467
frames=[self.frame("app:///utils/errors.js", True)],
466468
platform=self.platform,
@@ -470,7 +472,7 @@ def test_auto_source_code_config_starts_with_app_complex(self) -> None:
470472

471473
def test_auto_source_code_config_starts_with_multiple_dot_dot_slash(self) -> None:
472474
# It can handle relative paths
473-
self._process_and_assert_code_mapping(
475+
self._process_and_assert_configuration_changes(
474476
repo_trees={REPO1: ["packages/api/src/response.ts"]},
475477
frames=[self.frame("../../packages/api/src/response.ts", True)],
476478
platform=self.platform,
@@ -480,7 +482,7 @@ def test_auto_source_code_config_starts_with_multiple_dot_dot_slash(self) -> Non
480482

481483
def test_auto_source_code_config_starts_with_app_dot_dot_slash(self) -> None:
482484
# It can handle app:// urls with dot dot slashes
483-
self._process_and_assert_code_mapping(
485+
self._process_and_assert_configuration_changes(
484486
repo_trees={REPO1: ["services/event/index.js"]},
485487
frames=[self.frame("app:///../services/event/index.js", True)],
486488
platform=self.platform,
@@ -493,7 +495,7 @@ class TestGoDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
493495
platform = "go"
494496

495497
def test_auto_source_code_config_go_abs_filename(self) -> None:
496-
self._process_and_assert_code_mapping(
498+
self._process_and_assert_configuration_changes(
497499
repo_trees={REPO1: ["sentry/capybara.go"]},
498500
frames=[self.frame("/Users/JohnDoe/code/sentry/capybara.go", True)],
499501
platform=self.platform,
@@ -502,7 +504,7 @@ def test_auto_source_code_config_go_abs_filename(self) -> None:
502504
)
503505

504506
def test_auto_source_code_config_go_long_abs_filename(self) -> None:
505-
self._process_and_assert_code_mapping(
507+
self._process_and_assert_configuration_changes(
506508
repo_trees={REPO1: ["sentry/kangaroo.go"]},
507509
frames=[self.frame("/Users/JohnDoe/code/sentry/kangaroo.go", True)],
508510
platform=self.platform,
@@ -511,7 +513,7 @@ def test_auto_source_code_config_go_long_abs_filename(self) -> None:
511513
)
512514

513515
def test_auto_source_code_config_similar_but_incorrect_file(self) -> None:
514-
self._process_and_assert_no_code_mapping(
516+
self._process_and_assert_no_configuration_changes(
515517
repo_trees={REPO1: ["not-sentry/main.go"]},
516518
frames=[self.frame("Users/JohnDoe/src/sentry/main.go", True)],
517519
platform=self.platform,
@@ -527,7 +529,7 @@ class TestPhpDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
527529
]
528530

529531
def test_auto_source_code_config_basic_php(self) -> None:
530-
self._process_and_assert_code_mapping(
532+
self._process_and_assert_configuration_changes(
531533
repo_trees={REPO1: ["sentry/p/kanga.php"]},
532534
frames=[self.frame("/sentry/p/kanga.php", True)],
533535
platform=self.platform,
@@ -536,7 +538,7 @@ def test_auto_source_code_config_basic_php(self) -> None:
536538
)
537539

538540
def test_auto_source_code_config_different_roots_php(self) -> None:
539-
self._process_and_assert_code_mapping(
541+
self._process_and_assert_configuration_changes(
540542
repo_trees={REPO1: ["src/sentry/p/kanga.php"]},
541543
frames=[self.frame("/sentry/p/kanga.php", True)],
542544
platform=self.platform,
@@ -549,7 +551,7 @@ class TestCSharpDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
549551
platform = "csharp"
550552

551553
def test_auto_source_code_config_csharp_trivial(self) -> None:
552-
self._process_and_assert_code_mapping(
554+
self._process_and_assert_configuration_changes(
553555
repo_trees={REPO1: ["sentry/p/kanga.cs"]},
554556
frames=[self.frame("/sentry/p/kanga.cs", True)],
555557
platform=self.platform,
@@ -558,7 +560,7 @@ def test_auto_source_code_config_csharp_trivial(self) -> None:
558560
)
559561

560562
def test_auto_source_code_config_different_roots_csharp(self) -> None:
561-
self._process_and_assert_code_mapping(
563+
self._process_and_assert_configuration_changes(
562564
repo_trees={REPO1: ["src/sentry/p/kanga.cs"]},
563565
frames=[self.frame("/sentry/p/kanga.cs", True)],
564566
platform=self.platform,
@@ -567,7 +569,7 @@ def test_auto_source_code_config_different_roots_csharp(self) -> None:
567569
)
568570

569571
def test_auto_source_code_config_non_in_app_frame(self) -> None:
570-
self._process_and_assert_no_code_mapping(
572+
self._process_and_assert_no_configuration_changes(
571573
repo_trees={REPO1: ["sentry/src/functions.cs"]},
572574
frames=[self.frame("/sentry/p/vendor/sentry/src/functions.cs", False)],
573575
platform=self.platform,
@@ -578,7 +580,7 @@ class TestPythonDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
578580
platform = "python"
579581

580582
def test_auto_source_code_config_stack_and_source_root_do_not_match(self) -> None:
581-
self._process_and_assert_code_mapping(
583+
self._process_and_assert_configuration_changes(
582584
repo_trees={REPO1: ["src/sentry/foo/bar.py"]},
583585
frames=[self.frame("sentry/foo/bar.py", True)],
584586
platform=self.platform,
@@ -587,7 +589,7 @@ def test_auto_source_code_config_stack_and_source_root_do_not_match(self) -> Non
587589
)
588590

589591
def test_auto_source_code_config_no_normalization(self) -> None:
590-
self._process_and_assert_code_mapping(
592+
self._process_and_assert_configuration_changes(
591593
repo_trees={REPO1: ["sentry/foo/bar.py"]},
592594
frames=[self.frame("sentry/foo/bar.py", True)],
593595
platform=self.platform,
@@ -601,7 +603,7 @@ class TestJavaDeriveCodeMappings(LanguageSpecificDeriveCodeMappings):
601603

602604
def test_very_short_module_name(self) -> None:
603605
# No code mapping will be stored, however, we get what would have been created
604-
code_mappings, in_app_stack_trace_rules = self._process_and_assert_no_code_mapping(
606+
code_mappings, _ = self._process_and_assert_no_configuration_changes(
605607
repo_trees={REPO1: ["src/a/SomeShortPackageNameClass.java"]},
606608
frames=[
607609
{
@@ -614,11 +616,10 @@ def test_very_short_module_name(self) -> None:
614616
assert len(code_mappings) == 1
615617
assert code_mappings[0].stacktrace_root == "a/"
616618
assert code_mappings[0].source_path == "src/a/"
617-
assert in_app_stack_trace_rules == ["stack.module:a.** +app"]
618619

619620
def test_handles_dollar_sign_in_module(self) -> None:
620621
# No code mapping will be stored, however, we get what would have been created
621-
code_mappings, in_app_stack_trace_rules = self._process_and_assert_no_code_mapping(
622+
code_mappings, _ = self._process_and_assert_no_configuration_changes(
622623
repo_trees={REPO1: ["src/com/example/foo/Bar.kt"]},
623624
frames=[{"module": "com.example.foo.Bar$InnerClass", "abs_path": "Bar.kt"}],
624625
platform=self.platform,

0 commit comments

Comments
 (0)