Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert new_group1.status == GroupStatus.RESOLVED
assert new_group1.resolved_at is None
# this wont exist because it wasn't affected
assert not GroupSubscription.objects.filter(user=self.user, group=new_group1).exists()
new_group2 = Group.objects.get(id=group2.id)
assert new_group2.status == GroupStatus.RESOLVED
assert new_group2.resolved_at is not None
assert GroupSubscription.objects.filter(
user=self.user, group=new_group2, is_active=True
).exists()
# the ignored entry should not be included
new_group3 = Group.objects.get(id=group3.id)
assert new_group3.status == GroupStatus.IGNORED
assert new_group3.resolved_at is None
assert not GroupSubscription.objects.filter(user=self.user, group=new_group3)
new_group4 = Group.objects.get(id=group4.id)
assert new_group4.status == GroupStatus.UNRESOLVED
assert new_group4.resolved_at is None
assert not GroupSubscription.objects.filter(user=self.user, group=new_group4)
group3 = self.create_group(checksum="c" * 32, status=GroupStatus.IGNORED)
group4 = self.create_group(
project=self.create_project(slug="foo"),
checksum="b" * 32,
status=GroupStatus.UNRESOLVED,
)
self.login_as(user=self.user)
response = self.client.put(
u"{}?status=unresolved".format(self.path), data={"status": "resolved"}, format="json"
)
assert response.status_code == 200, response.data
assert response.data == {"status": "resolved", "statusDetails": {}}
# the previously resolved entry should not be included
new_group1 = Group.objects.get(id=group1.id)
assert new_group1.status == GroupStatus.RESOLVED
assert new_group1.resolved_at is None
# this wont exist because it wasn't affected
assert not GroupSubscription.objects.filter(user=self.user, group=new_group1).exists()
new_group2 = Group.objects.get(id=group2.id)
assert new_group2.status == GroupStatus.RESOLVED
assert new_group2.resolved_at is not None
assert GroupSubscription.objects.filter(
user=self.user, group=new_group2, is_active=True
).exists()
# the ignored entry should not be included
new_group3 = Group.objects.get(id=group3.id)
self.event3 = self.store_event(
data={
'fingerprint': ['put-me-in-group1'],
'event_id': 'c' * 32,
'message': 'foo',
'environment': 'production',
'tags': {
'server': 'example.com',
},
'timestamp': (now - timedelta(days=2)).isoformat()[:19]
},
project_id=self.project.id
)
self.group1 = Group.objects.get(id=self.event3.group.id)
assert self.event1.group.id == self.group1.id
assert self.group1.first_seen == self.event1.datetime
assert self.group1.last_seen == self.event3.datetime
self.group1.status = GroupStatus.UNRESOLVED
self.group1.times_seen = 5
self.group1.save()
self.event2 = self.store_event(
data={
'fingerprint': ['put-me-in-group2'],
'event_id': 'b' * 32,
'message': 'bar',
'environment': 'staging',
'tags': {
self.login_as(user=self.user)
response = self.client.put(
u"{}?status=unresolved".format(self.path), data={"status": "resolved"}, format="json"
)
assert response.status_code == 200, response.data
assert response.data == {"status": "resolved", "statusDetails": {}}
# the previously resolved entry should not be included
new_group1 = Group.objects.get(id=group1.id)
assert new_group1.status == GroupStatus.RESOLVED
assert new_group1.resolved_at is None
# this wont exist because it wasn't affected
assert not GroupSubscription.objects.filter(user=self.user, group=new_group1).exists()
new_group2 = Group.objects.get(id=group2.id)
assert new_group2.status == GroupStatus.RESOLVED
assert new_group2.resolved_at is not None
assert GroupSubscription.objects.filter(
user=self.user, group=new_group2, is_active=True
).exists()
# the ignored entry should not be included
new_group3 = Group.objects.get(id=group3.id)
assert new_group3.status == GroupStatus.IGNORED
assert new_group3.resolved_at is None
assert not GroupSubscription.objects.filter(user=self.user, group=new_group3)
new_group4 = Group.objects.get(id=group4.id)
assert new_group4.status == GroupStatus.UNRESOLVED
commit__key="b" * 40, commit__repository_id=repo.id, release=release
).exists()
assert ReleaseCommit.objects.filter(
commit__key="c" * 40, commit__repository_id=repo.id, release=release
).exists()
assert GroupLink.objects.filter(
group_id=group.id, linked_type=GroupLink.LinkedType.commit, linked_id=commit_c.id
).exists()
assert GroupResolution.objects.filter(group=group, release=release).exists()
assert (
GroupResolution.objects.get(group=group, release=release).status
== GroupResolution.Status.resolved
)
assert Group.objects.get(id=group.id).status == GroupStatus.RESOLVED
latest_commit = Commit.objects.get(repository_id=repo.id, key="a" * 40)
release = Release.objects.get(id=release.id)
assert release.commit_count == 3
assert release.authors == [six.text_type(author.id)]
assert release.last_commit_id == latest_commit.id
def test_set_unresolved(self):
release = self.create_release(project=self.project, version="abc")
group = self.create_group(checksum="a" * 32, status=GroupStatus.RESOLVED)
GroupResolution.objects.create(group=group, release=release)
self.login_as(user=self.user)
response = self.get_valid_response(qs_params={"id": group.id}, status="unresolved")
assert response.data == {"status": "unresolved", "statusDetails": {}}
group = Group.objects.get(id=group.id)
assert group.status == GroupStatus.UNRESOLVED
self.assertNoResolution(group)
assert GroupSubscription.objects.filter(
user=self.user, group=group, is_active=True
).exists()
)
assert response.data == {"status": "resolved", "statusDetails": {}}
new_group1 = Group.objects.get(id=group1.id)
assert new_group1.resolved_at is not None
assert new_group1.status == GroupStatus.RESOLVED
new_group2 = Group.objects.get(id=group2.id)
assert new_group2.resolved_at is not None
assert new_group2.status == GroupStatus.RESOLVED
assert GroupSubscription.objects.filter(
user=self.user, group=new_group2, is_active=True
).exists()
new_group3 = Group.objects.get(id=group3.id)
assert new_group3.resolved_at is None
assert new_group3.status == GroupStatus.IGNORED
new_group4 = Group.objects.get(id=group4.id)
assert new_group4.resolved_at is None
assert new_group4.status == GroupStatus.UNRESOLVED
linked_type=GroupLink.LinkedType.issue,
linked_id=external_issue.id,
relationship=GroupLink.Relationship.references,
)[0]
self.login_as(user=self.user)
url = u"{url}?id={group.id}".format(url=self.path, group=group)
with self.tasks():
with self.feature({"organizations:integrations-issue-sync": True}):
response = self.client.put(url, data={"status": "unresolved"}, format="json")
assert response.status_code == 200
assert response.data == {"status": "unresolved", "statusDetails": {}}
group = Group.objects.get(id=group.id)
assert group.status == GroupStatus.UNRESOLVED
self.assertNoResolution(group)
assert GroupSubscription.objects.filter(
user=self.user, group=group, is_active=True
).exists()
mock_sync_status_outbound.assert_called_once_with(
external_issue, False, group.project_id
)
group = self.create_group(checksum="a" * 32, status=GroupStatus.UNRESOLVED)
self.login_as(user=self.user)
url = u"{url}?id={group.id}".format(url=self.path, group=group)
response = self.client.put(
url,
data={"status": "resolved", "statusDetails": {"inRelease": "latest"}},
format="json",
)
assert response.status_code == 200
assert response.data["status"] == "resolved"
assert response.data["statusDetails"]["inRelease"] == release.version
assert response.data["statusDetails"]["actor"]["id"] == six.text_type(self.user.id)
group = Group.objects.get(id=group.id)
assert group.status == GroupStatus.RESOLVED
resolution = GroupResolution.objects.get(group=group)
assert resolution.release == release
assert resolution.type == GroupResolution.Type.in_release
assert resolution.status == GroupResolution.Status.resolved
assert resolution.actor_id == self.user.id
assert GroupSubscription.objects.filter(
user=self.user, group=group, is_active=True
).exists()
activity = Activity.objects.get(group=group, type=Activity.SET_RESOLVED_IN_RELEASE)
assert activity.data["version"] == release.version
def resolve(request, project):
gid = request.REQUEST.get('gid')
if not gid:
return HttpResponseForbidden()
try:
group = Group.objects.get(pk=gid)
except Group.DoesNotExist:
return HttpResponseForbidden()
if group.project and group.project.pk not in get_project_list(request.user):
return HttpResponseForbidden()
Group.objects.filter(pk=group.pk).update(status=1)
group.status = 1
if not request.is_ajax():
return HttpResponseRedirect(request.META.get('HTTP_REFERER') or reverse('sentry'))
data = [
(m.pk, {
'html': render_to_string('sentry/partial/_group.html', {
'group': m,