-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests(derived_code_mappings): Refactor the test a bit #86189
Conversation
Changes included: * Clearly show what frame is used within a specific test * Force calling helper functions with keyword arguments
"""Helper function to prevent creating an event without a platform.""" | ||
test_data = {"platform": platform, "stacktrace": {"frames": frames}} | ||
return self.store_event(data=test_data, project_id=self.project.id) | ||
# XXX: In the future fix store_event to return the correct type | ||
return cast(GroupEvent, self.store_event(data=test_data, project_id=self.project.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patch("sentry.utils.metrics.incr") as mock_incr, | ||
): | ||
process_event(self.project.id, self.event.group_id, self.event.event_id) | ||
event = self.create_event(frames, platform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert not RepositoryProjectPathConfig.objects.exists() | ||
return code_mappings | ||
|
||
def frame(self, filename: str, in_app: bool | None = True) -> dict[str, str | bool]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New helper function. Not necessary but it helps shorten lines.
platform: str, | ||
) -> list[CodeMapping]: | ||
with patch(GET_TREES_FOR_ORG, return_value=self._get_trees_for_org(repo_files)): | ||
event = self.create_event(frames, platform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"in_app": True, "filename": "\\sentry\\dog\\cat\\parrot.py"}, | ||
{"in_app": True, "filename": "C:sentry\\tasks.py"}, | ||
{"in_app": True, "filename": "D:\\Users\\code\\sentry\\models\\release.py"}, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes included:
This forces writing tests by declaring frames within the test rather than having a list at the top of the class.
