Skip to content

Commit 557ada4

Browse files
authored
chore(issues): Opt in a few more endpoint tests to stronger types (#82382)
`tests.sentry.issues.endpoints.test_organization_group_index` is the only remaining before we can just fully opt in `tests.sentry.issues.endpoints.*`.
1 parent ca23764 commit 557ada4

6 files changed

+70
-121
lines changed

Diff for: pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,12 @@ module = [
511511
"tests.sentry.issues.endpoints.test_group_activities",
512512
"tests.sentry.issues.endpoints.test_group_details",
513513
"tests.sentry.issues.endpoints.test_group_event_details",
514+
"tests.sentry.issues.endpoints.test_group_events",
514515
"tests.sentry.issues.endpoints.test_group_hashes",
515516
"tests.sentry.issues.endpoints.test_group_notes",
517+
"tests.sentry.issues.endpoints.test_group_notes_details",
518+
"tests.sentry.issues.endpoints.test_group_participants",
519+
"tests.sentry.issues.endpoints.test_group_similar_issues_embeddings",
516520
"tests.sentry.issues.endpoints.test_group_tombstone",
517521
"tests.sentry.issues.endpoints.test_group_tombstone_details",
518522
"tests.sentry.issues.endpoints.test_organization_group_search_views",
@@ -521,6 +525,7 @@ module = [
521525
"tests.sentry.issues.endpoints.test_project_group_stats",
522526
"tests.sentry.issues.endpoints.test_project_stacktrace_link",
523527
"tests.sentry.issues.endpoints.test_related_issues",
528+
"tests.sentry.issues.endpoints.test_shared_group_details",
524529
"tests.sentry.issues.endpoints.test_source_map_debug",
525530
"tests.sentry.issues.endpoints.test_team_groups_old",
526531
"tests.sentry.issues.test_attributes",

Diff for: tests/sentry/issues/endpoints/test_group_events.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import timedelta
22

33
from django.utils import timezone
4+
from rest_framework.response import Response
45

56
from sentry.issues.grouptype import ProfileFileIOGroupType
67
from sentry.testutils.cases import APITestCase, PerformanceIssueTestCase, SnubaTestCase
@@ -15,10 +16,10 @@ def setUp(self) -> None:
1516
self.min_ago = before_now(minutes=1)
1617
self.two_min_ago = before_now(minutes=2)
1718

18-
def do_request(self, url: str):
19+
def do_request(self, url: str) -> Response:
1920
return self.client.get(url, format="json")
2021

21-
def _parse_links(self, header):
22+
def _parse_links(self, header: str) -> dict[str | None, dict[str, str | None]]:
2223
# links come in {url: {...attrs}}, but we need {rel: {...attrs}}
2324
links = {}
2425
for url, attrs in parse_link_header(header).items():

Diff for: tests/sentry/issues/endpoints/test_group_notes_details.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import cached_property
2-
from unittest.mock import patch
2+
from unittest.mock import MagicMock, patch
33

44
import responses
55

@@ -16,7 +16,7 @@
1616

1717

1818
class GroupNotesDetailsTest(APITestCase):
19-
def setUp(self):
19+
def setUp(self) -> None:
2020
super().setUp()
2121
self.activity.data["external_id"] = "123"
2222
self.activity.save()
@@ -43,10 +43,10 @@ def setUp(self):
4343
)
4444

4545
@cached_property
46-
def url(self):
46+
def url(self) -> str:
4747
return f"/api/0/issues/{self.group.id}/comments/{self.activity.id}/"
4848

49-
def test_delete(self):
49+
def test_delete(self) -> None:
5050
self.login_as(user=self.user)
5151

5252
url = self.url
@@ -59,7 +59,7 @@ def test_delete(self):
5959

6060
assert Group.objects.get(id=self.group.id).num_comments == 0
6161

62-
def test_delete_comment_and_subscription(self):
62+
def test_delete_comment_and_subscription(self) -> None:
6363
"""Test that if a user deletes their comment on an issue, we delete the subscription too"""
6464
self.login_as(user=self.user)
6565
event = self.store_event(data={}, project_id=self.project.id)
@@ -91,7 +91,7 @@ def test_delete_comment_and_subscription(self):
9191
reason=GroupSubscriptionReason.comment,
9292
).exists()
9393

94-
def test_delete_multiple_comments(self):
94+
def test_delete_multiple_comments(self) -> None:
9595
"""Test that if a user has commented multiple times on an issue and deletes one, we don't remove the subscription"""
9696
self.login_as(user=self.user)
9797
event = self.store_event(data={}, project_id=self.project.id)
@@ -130,7 +130,7 @@ def test_delete_multiple_comments(self):
130130

131131
@patch("sentry.integrations.mixins.issues.IssueBasicIntegration.update_comment")
132132
@responses.activate
133-
def test_put(self, mock_update_comment):
133+
def test_put(self, mock_update_comment: MagicMock) -> None:
134134
self.login_as(user=self.user)
135135

136136
url = self.url
@@ -154,7 +154,7 @@ def test_put(self, mock_update_comment):
154154
assert mock_update_comment.call_args[0][2] == activity
155155

156156
@responses.activate
157-
def test_put_ignore_mentions(self):
157+
def test_put_ignore_mentions(self) -> None:
158158
GroupLink.objects.filter(group_id=self.group.id).delete()
159159
self.login_as(user=self.user)
160160

@@ -179,7 +179,7 @@ def test_put_ignore_mentions(self):
179179
}
180180

181181
@patch("sentry.integrations.mixins.issues.IssueBasicIntegration.update_comment")
182-
def test_put_no_external_id(self, mock_update_comment):
182+
def test_put_no_external_id(self, mock_update_comment: MagicMock) -> None:
183183
del self.activity.data["external_id"]
184184
self.activity.save()
185185
self.login_as(user=self.user)

Diff for: tests/sentry/issues/endpoints/test_group_participants.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
from collections.abc import Callable
2+
3+
from sentry.models.group import Group
14
from sentry.models.groupsubscription import GroupSubscription
25
from sentry.testutils.cases import APITestCase
36

47

58
class GroupParticipantsTest(APITestCase):
6-
def setUp(self):
9+
def setUp(self) -> None:
710
super().setUp()
811
self.login_as(self.user)
912

10-
def _get_path_functions(self):
13+
def _get_path_functions(self) -> tuple[Callable[[Group], str], Callable[[Group], str]]:
1114
# The urls for group participants are supported both with an org slug and without.
1215
# We test both as long as we support both.
1316
# Because removing old urls takes time and consideration of the cost of breaking lingering references, a
@@ -17,7 +20,7 @@ def _get_path_functions(self):
1720
lambda group: f"/api/0/organizations/{self.organization.slug}/issues/{group.id}/participants/",
1821
)
1922

20-
def test_simple(self):
23+
def test_simple(self) -> None:
2124
group = self.create_group()
2225
GroupSubscription.objects.create(
2326
user_id=self.user.id, group=group, project=group.project, is_active=True

0 commit comments

Comments
 (0)