Skip to content

Commit 2110d6d

Browse files
committed
add tests
1 parent cca7bbf commit 2110d6d

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

src/sentry/api/helpers/group_index/update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def update_groups(
225225
)
226226
if user_options:
227227
self_assign_issue = user_options[0].value
228-
229228
if search_fn and not group_ids:
230229
try:
231230
cursor_result, _ = search_fn(

src/sentry/api/helpers/group_index/validators/status_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ def validate_inUpcomingRelease(self, value: bool) -> "Release":
7171
.order_by("-sort")[0]
7272
)
7373
except IndexError:
74-
raise serializers.ValidationError("No release data present in the system.'")
74+
raise serializers.ValidationError("No release data present in the system.")

tests/sentry/issues/endpoints/test_organization_group_index.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4954,6 +4954,22 @@ def test_update_priority_no_change(self) -> None:
49544954
group=group2, type=ActivityType.SET_PRIORITY.value, user_id=self.user.id
49554955
).exists()
49564956

4957+
def test_resolved_in_upcoming_release_multiple_projects(self) -> None:
4958+
project_2 = self.create_project(slug="foo")
4959+
group1 = self.create_group(status=GroupStatus.UNRESOLVED)
4960+
group2 = self.create_group(status=GroupStatus.UNRESOLVED, project=project_2)
4961+
4962+
self.login_as(user=self.user)
4963+
response = self.get_response(
4964+
qs_params={
4965+
"id": [group1.id, group2.id],
4966+
"statd": "resolved",
4967+
"statusDetails": {"inUpcomingRelease": True},
4968+
}
4969+
)
4970+
4971+
assert response.status_code == 400
4972+
49574973

49584974
class GroupDeleteTest(APITestCase, SnubaTestCase):
49594975
endpoint = "sentry-api-0-organization-group-index"

tests/snuba/api/endpoints/test_project_group_index.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,44 @@ def test_set_resolved_in_upcoming_release(self):
830830
)
831831
assert activity.data["version"] == ""
832832

833+
def test_upcoming_release_flag_validation(self):
834+
release = Release.objects.create(organization_id=self.project.organization_id, version="a")
835+
release.add_project(self.project)
836+
837+
group = self.create_group(status=GroupStatus.UNRESOLVED)
838+
839+
self.login_as(user=self.user)
840+
841+
url = f"{self.path}?id={group.id}"
842+
response = self.client.put(
843+
url,
844+
data={"status": "resolved", "statusDetails": {"inUpcomingRelease": True}},
845+
format="json",
846+
)
847+
assert response.status_code == 400
848+
assert (
849+
response.data["statusDetails"]["inUpcomingRelease"][0]
850+
== "Your organization does not have access to this feature."
851+
)
852+
853+
@with_feature("organizations:resolve-in-upcoming-release")
854+
def test_upcoming_release_release_validation(self):
855+
group = self.create_group(status=GroupStatus.UNRESOLVED)
856+
857+
self.login_as(user=self.user)
858+
859+
url = f"{self.path}?id={group.id}"
860+
response = self.client.put(
861+
url,
862+
data={"status": "resolved", "statusDetails": {"inUpcomingRelease": True}},
863+
format="json",
864+
)
865+
assert response.status_code == 400
866+
assert (
867+
response.data["statusDetails"]["inUpcomingRelease"][0]
868+
== "No release data present in the system."
869+
)
870+
833871
def test_set_resolved_in_explicit_commit_unreleased(self):
834872
repo = self.create_repo(project=self.project, name=self.project.name)
835873
commit = self.create_commit(project=self.project, repo=repo)

0 commit comments

Comments
 (0)