<s> from __future__ import absolute_import <EOL> from datetime import timedelta <EOL> from django . utils import timezone <EOL> from exam import fixture <EOL> from mock import patch <EOL> from sentry . models import ( <EOL> Activity , EventMapping , Group , GroupBookmark , GroupResolution , GroupSeen , <EOL> GroupSnooze , GroupStatus , Release <EOL> ) <EOL> from sentry . testutils import APITestCase <EOL> from sentry . testutils . helpers import parse_link_header <EOL> class GroupListTest ( APITestCase ) : <EOL> def _parse_links ( self , header ) : <EOL> links = { } <EOL> for url , attrs in parse_link_header ( header ) . iteritems ( ) : <EOL> links [ attrs [ '<STR_LIT>' ] ] = attrs <EOL> attrs [ '<STR_LIT>' ] = url <EOL> return links <EOL> @ fixture <EOL> def path ( self ) : <EOL> return '<STR_LIT>' . format ( <EOL> self . project . organization . slug , <EOL> self . project . slug , <EOL> ) <EOL> def test_sort_by_date_with_tag ( self ) : <EOL> now = timezone . now ( ) <EOL> group1 = self . create_group ( <EOL> checksum = '<STR_LIT:a>' * <NUM_LIT:32> , <EOL> last_seen = now - timedelta ( seconds = <NUM_LIT:1> ) , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( <EOL> '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group1 . id ) <EOL> def test_simple_pagination ( self ) : <EOL> now = timezone . now ( ) . replace ( microsecond = <NUM_LIT:0> ) <EOL> group1 = self . create_group ( <EOL> checksum = '<STR_LIT:a>' * <NUM_LIT:32> , <EOL> last_seen = now - timedelta ( seconds = <NUM_LIT:1> ) , <EOL> ) <EOL> group2 = self . create_group ( <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , <EOL> last_seen = now , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( <EOL> '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group2 . id ) <EOL> links = self . _parse_links ( response [ '<STR_LIT>' ] ) <EOL> assert links [ '<STR_LIT>' ] [ '<STR_LIT>' ] == '<STR_LIT:false>' <EOL> assert links [ '<STR_LIT>' ] [ '<STR_LIT>' ] == '<STR_LIT:true>' <EOL> print ( links [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> response = self . client . get ( links [ '<STR_LIT>' ] [ '<STR_LIT>' ] , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group1 . id ) <EOL> links = self . _parse_links ( response [ '<STR_LIT>' ] ) <EOL> assert links [ '<STR_LIT>' ] [ '<STR_LIT>' ] == '<STR_LIT:true>' <EOL> assert links [ '<STR_LIT>' ] [ '<STR_LIT>' ] == '<STR_LIT:false>' <EOL> def test_stats_period ( self ) : <EOL> now = timezone . now ( ) <EOL> self . create_group ( <EOL> checksum = '<STR_LIT:a>' * <NUM_LIT:32> , <EOL> last_seen = now - timedelta ( seconds = <NUM_LIT:1> ) , <EOL> ) <EOL> self . create_group ( <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , <EOL> last_seen = now , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT> <EOL> def test_auto_resolved ( self ) : <EOL> project = self . project <EOL> project . update_option ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> now = timezone . now ( ) <EOL> self . create_group ( <EOL> checksum = '<STR_LIT:a>' * <NUM_LIT:32> , <EOL> last_seen = now - timedelta ( days = <NUM_LIT:1> ) , <EOL> ) <EOL> group2 = self . create_group ( <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , <EOL> last_seen = now , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( self . path , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group2 . id ) <EOL> def test_lookup_by_event_id ( self ) : <EOL> project = self . project <EOL> project . update_option ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> group = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> ) <EOL> self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> ) <EOL> EventMapping . objects . create ( <EOL> event_id = '<STR_LIT:c>' * <NUM_LIT:32> , <EOL> project = group . project , <EOL> group = group , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path , '<STR_LIT:c>' * <NUM_LIT:32> ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group . id ) <EOL> def test_lookup_by_event_id_with_whitespace ( self ) : <EOL> project = self . project <EOL> project . update_option ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> group = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> ) <EOL> self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> ) <EOL> EventMapping . objects . create ( <EOL> event_id = '<STR_LIT:c>' * <NUM_LIT:32> , <EOL> project = group . project , <EOL> group = group , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path , '<STR_LIT:c>' * <NUM_LIT:32> ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( group . id ) <EOL> def test_lookup_by_unknown_event_id ( self ) : <EOL> project = self . project <EOL> project . update_option ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> ) <EOL> self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . get ( '<STR_LIT>' . format ( self . path , '<STR_LIT:c>' * <NUM_LIT:32> ) , <EOL> format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:0> <EOL> class GroupUpdateTest ( APITestCase ) : <EOL> @ fixture <EOL> def path ( self ) : <EOL> return '<STR_LIT>' . format ( <EOL> self . project . organization . slug , <EOL> self . project . slug , <EOL> ) <EOL> def test_global_resolve ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> group4 = self . create_group ( <EOL> project = self . create_project ( slug = '<STR_LIT:foo>' ) , <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . put ( <EOL> '<STR_LIT>' . format ( self . path ) , <EOL> data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , <EOL> format = '<STR_LIT>' , <EOL> ) <EOL> assert response . status_code == <NUM_LIT:200> , response . data <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> } <EOL> new_group1 = Group . objects . get ( id = group1 . id ) <EOL> assert new_group1 . status == GroupStatus . RESOLVED <EOL> assert new_group1 . resolved_at is None <EOL> new_group2 = Group . objects . get ( id = group2 . id ) <EOL> assert new_group2 . status == GroupStatus . RESOLVED <EOL> assert new_group2 . resolved_at is not None <EOL> new_group3 = Group . objects . get ( id = group3 . id ) <EOL> assert new_group3 . status == GroupStatus . MUTED <EOL> assert new_group3 . resolved_at is None <EOL> new_group4 = Group . objects . get ( id = group4 . id ) <EOL> assert new_group4 . status == GroupStatus . UNRESOLVED <EOL> assert new_group4 . resolved_at is None <EOL> def test_selective_status_update ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> group4 = self . create_group ( <EOL> project = self . create_project ( slug = '<STR_LIT:foo>' ) , <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> group4 = group4 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> } <EOL> new_group1 = Group . objects . get ( id = group1 . id ) <EOL> assert new_group1 . resolved_at is None <EOL> new_group2 = Group . objects . get ( id = group2 . id ) <EOL> assert new_group2 . resolved_at is not None <EOL> assert new_group2 . status == GroupStatus . RESOLVED <EOL> new_group3 = Group . objects . get ( id = group3 . id ) <EOL> assert new_group3 . resolved_at is None <EOL> assert new_group3 . status == GroupStatus . MUTED <EOL> new_group4 = Group . objects . get ( id = group4 . id ) <EOL> assert new_group4 . resolved_at is None <EOL> assert new_group4 . status == GroupStatus . UNRESOLVED <EOL> def test_set_resolved_in_next_release ( self ) : <EOL> release = Release . objects . create ( project = self . project , version = '<STR_LIT:a>' ) <EOL> group = self . create_group ( <EOL> checksum = '<STR_LIT:a>' * <NUM_LIT:32> , <EOL> status = GroupStatus . UNRESOLVED , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group = group , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : True , <EOL> } , <EOL> } <EOL> group = Group . objects . get ( id = group . id ) <EOL> assert group . status == GroupStatus . RESOLVED <EOL> assert GroupResolution . objects . filter ( <EOL> group = group , <EOL> release = release , <EOL> ) . exists ( ) <EOL> activity = Activity . objects . get ( <EOL> group = group , <EOL> type = Activity . SET_RESOLVED_IN_RELEASE , <EOL> ) <EOL> assert activity . data [ '<STR_LIT:version>' ] == '<STR_LIT>' <EOL> def test_set_unresolved ( self ) : <EOL> group = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group = group , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> } <EOL> group = Group . objects . get ( id = group . id ) <EOL> assert group . status == GroupStatus . UNRESOLVED <EOL> def test_set_unresolved_on_snooze ( self ) : <EOL> group = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> GroupSnooze . objects . create ( <EOL> group = group , <EOL> until = timezone . now ( ) - timedelta ( days = <NUM_LIT:1> ) , <EOL> ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group = group , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> } <EOL> group = Group . objects . get ( id = group . id ) <EOL> assert group . status == GroupStatus . UNRESOLVED <EOL> def test_snooze_duration ( self ) : <EOL> group = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group = group , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:30> , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> snooze = GroupSnooze . objects . get ( group = group ) <EOL> assert snooze . until > timezone . now ( ) + timedelta ( minutes = <NUM_LIT> ) <EOL> assert snooze . until < timezone . now ( ) + timedelta ( minutes = <NUM_LIT> ) <EOL> assert response . data == { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : snooze . until , <EOL> } , <EOL> } <EOL> group = Group . objects . get ( id = group . id ) <EOL> assert group . get_status ( ) == GroupStatus . MUTED <EOL> def test_set_bookmarked ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> group4 = self . create_group ( <EOL> project = self . create_project ( slug = '<STR_LIT:foo>' ) , <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> group4 = group4 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT>' : '<STR_LIT:true>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT>' : True , <EOL> } <EOL> bookmark1 = GroupBookmark . objects . filter ( group = group1 , user = self . user ) <EOL> assert bookmark1 . exists ( ) <EOL> bookmark2 = GroupBookmark . objects . filter ( group = group2 , user = self . user ) <EOL> assert bookmark2 . exists ( ) <EOL> bookmark3 = GroupBookmark . objects . filter ( group = group3 , user = self . user ) <EOL> assert not bookmark3 . exists ( ) <EOL> bookmark4 = GroupBookmark . objects . filter ( group = group4 , user = self . user ) <EOL> assert not bookmark4 . exists ( ) <EOL> def test_set_public ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , is_public = False ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , is_public = False ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT>' : '<STR_LIT:true>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT>' : True , <EOL> } <EOL> new_group1 = Group . objects . get ( id = group1 . id ) <EOL> assert new_group1 . is_public <EOL> new_group2 = Group . objects . get ( id = group2 . id ) <EOL> assert new_group2 . is_public <EOL> def test_set_private ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , is_public = True ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , is_public = True ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT>' : '<STR_LIT:false>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT>' : False , <EOL> } <EOL> new_group1 = Group . objects . get ( id = group1 . id ) <EOL> assert not new_group1 . is_public <EOL> new_group2 = Group . objects . get ( id = group2 . id ) <EOL> assert not new_group2 . is_public <EOL> def test_set_has_seen ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> group4 = self . create_group ( <EOL> project = self . create_project ( slug = '<STR_LIT:foo>' ) , <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> group4 = group4 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT>' : '<STR_LIT:true>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data == { <EOL> '<STR_LIT>' : True , <EOL> } <EOL> r1 = GroupSeen . objects . filter ( group = group1 , user = self . user ) <EOL> assert r1 . exists ( ) <EOL> r2 = GroupSeen . objects . filter ( group = group2 , user = self . user ) <EOL> assert r2 . exists ( ) <EOL> r3 = GroupSeen . objects . filter ( group = group3 , user = self . user ) <EOL> assert not r3 . exists ( ) <EOL> r4 = GroupSeen . objects . filter ( group = group4 , user = self . user ) <EOL> assert not r4 . exists ( ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_merge ( self , merge_group ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , times_seen = <NUM_LIT:1> ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , times_seen = <NUM_LIT:50> ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , times_seen = <NUM_LIT:2> ) <EOL> self . create_group ( checksum = '<STR_LIT:d>' * <NUM_LIT:32> ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> group3 = group3 , <EOL> ) <EOL> response = self . client . put ( url , data = { <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert response . data [ '<STR_LIT>' ] [ '<STR_LIT>' ] == str ( group2 . id ) <EOL> assert sorted ( response . data [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) == [ <EOL> str ( group1 . id ) , <EOL> str ( group3 . id ) , <EOL> ] <EOL> assert len ( merge_group . mock_calls ) == <NUM_LIT:2> <EOL> merge_group . delay . assert_any_call ( from_object_id = group1 . id , to_object_id = group2 . id ) <EOL> merge_group . delay . assert_any_call ( from_object_id = group3 . id , to_object_id = group2 . id ) <EOL> class GroupDeleteTest ( APITestCase ) : <EOL> @ fixture <EOL> def path ( self ) : <EOL> return '<STR_LIT>' . format ( <EOL> self . project . organization . slug , <EOL> self . project . slug , <EOL> ) <EOL> def test_global_is_forbidden ( self ) : <EOL> self . login_as ( user = self . user ) <EOL> response = self . client . delete ( self . path , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT> <EOL> def test_delete_by_id ( self ) : <EOL> group1 = self . create_group ( checksum = '<STR_LIT:a>' * <NUM_LIT:32> , status = GroupStatus . RESOLVED ) <EOL> group2 = self . create_group ( checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> group3 = self . create_group ( checksum = '<STR_LIT:c>' * <NUM_LIT:32> , status = GroupStatus . MUTED ) <EOL> group4 = self . create_group ( <EOL> project = self . create_project ( slug = '<STR_LIT:foo>' ) , <EOL> checksum = '<STR_LIT:b>' * <NUM_LIT:32> , status = GroupStatus . UNRESOLVED ) <EOL> self . login_as ( user = self . user ) <EOL> url = '<STR_LIT>' . format ( <EOL> url = self . path , <EOL> group1 = group1 , <EOL> group2 = group2 , <EOL> group4 = group4 , <EOL> ) <EOL> with self . tasks ( ) : <EOL> response = self . client . delete ( url , format = '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT> <EOL> new_group1 = Group . objects . filter ( id = group1 . id ) <EOL> assert not new_group1 . exists ( ) <EOL> new_group2 = Group . objects . filter ( id = group2 . id ) <EOL> assert not new_group2 . exists ( ) <EOL> new_group3 = Group . objects . filter ( id = group3 . id ) <EOL> assert new_group3 . exists ( ) <EOL> new_group4 = Group . objects . filter ( id = group4 . id ) <EOL> assert new_group4 . exists ( ) </s>
