<s> from __future__ import absolute_import <EOL> from mock import Mock , patch <EOL> from sentry . models import EventTag , TagKey , TagValue <EOL> from sentry . testutils import TestCase <EOL> from sentry . tasks . post_process import index_event_tags , post_process_group <EOL> class PostProcessGroupTest ( TestCase ) : <EOL> @ patch ( '<STR_LIT>' , Mock ( ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_rule_processor ( self , mock_processor ) : <EOL> group = self . create_group ( project = self . project ) <EOL> event = self . create_event ( group = group ) <EOL> mock_callback = Mock ( ) <EOL> mock_futures = [ Mock ( ) ] <EOL> mock_processor . return_value . apply . return_value = [ <EOL> ( mock_callback , mock_futures ) , <EOL> ] <EOL> post_process_group ( <EOL> event = event , <EOL> is_new = True , <EOL> is_regression = False , <EOL> is_sample = False , <EOL> ) <EOL> mock_processor . assert_called_once_with ( event , True , False , False ) <EOL> mock_processor . return_value . apply . assert_called_once_with ( ) <EOL> mock_callback . assert_called_once_with ( event , mock_futures ) <EOL> class IndexEventTagsTest ( TestCase ) : <EOL> def test_simple ( self ) : <EOL> group = self . create_group ( project = self . project ) <EOL> event = self . create_event ( group = group ) <EOL> with self . tasks ( ) : <EOL> index_event_tags . delay ( <EOL> event_id = event . id , <EOL> project_id = self . project . id , <EOL> tags = [ ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ) <EOL> tags = list ( EventTag . objects . filter ( <EOL> event_id = event . id , <EOL> ) . values_list ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> assert len ( tags ) == <NUM_LIT:2> <EOL> tagkey = TagKey . objects . get ( <EOL> key = '<STR_LIT:foo>' , <EOL> project = self . project , <EOL> ) <EOL> tagvalue = TagValue . objects . get ( <EOL> key = '<STR_LIT:foo>' , <EOL> value = '<STR_LIT:bar>' , <EOL> project = self . project , <EOL> ) <EOL> assert ( tagkey . id , tagvalue . id ) in tags <EOL> tagkey = TagKey . objects . get ( <EOL> key = '<STR_LIT>' , <EOL> project = self . project , <EOL> ) <EOL> tagvalue = TagValue . objects . get ( <EOL> key = '<STR_LIT>' , <EOL> value = '<STR_LIT>' , <EOL> project = self . project , <EOL> ) <EOL> assert ( tagkey . id , tagvalue . id ) in tags <EOL> with self . tasks ( ) : <EOL> index_event_tags . delay ( <EOL> event_id = event . id , <EOL> project_id = self . project . id , <EOL> tags = [ ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ) <EOL> queryset = EventTag . objects . filter ( <EOL> event_id = event . id , <EOL> ) <EOL> assert queryset . count ( ) == <NUM_LIT:2> </s>
