#NEWLINE# @ mock . patch ( 'changes.listeners.analytics_notifier.categorize.categorize' ) #NEWLINE# @ mock . patch ( 'changes.listeners.analytics_notifier._get_rules' ) #NEWLINE# def test_tagged_log( self , get_rules_fn , categorize_fn ) : #NEWLINE# #INDENT# project = self . create_project ( name = 'test' , slug = 'project-slug' ) #NEWLINE# build = self . create_build ( project , result = Result . failed , target = 'D1' , label = 'Some sweet diff' ) #NEWLINE# job = self . create_job ( build = build , result = Result . failed , status = Status . finished ) #NEWLINE# phase = self . create_jobphase ( job = job ) #NEWLINE# step = self . create_jobstep ( phase = phase ) #NEWLINE# logsource = self . create_logsource ( step = step , name = 'loglog' ) #NEWLINE# chunks = [ 'Some log text\n' , 'Hey, some more log text.' ] #NEWLINE# offset = 0 #NEWLINE# for c in chunks : #NEWLINE# #INDENT# self . create_logchunk ( source = logsource , text = c , offset = offset ) #NEWLINE# offset += len ( c ) #NEWLINE# #UNINDENT# fake_rules = object ( ) #NEWLINE# get_rules_fn . return_value = fake_rules #NEWLINE# categorize_fn . return_value = ( { 'tag1' , 'tag2' } , { 'tag1' , 'tag2' } ) #NEWLINE# tags_by_step = None #NEWLINE# with mock . patch ( 'changes.listeners.analytics_notifier._incr' ) as incr : #NEWLINE# #INDENT# tags_by_step = _categorize_step_logs ( build ) #NEWLINE# incr . assert_any_call ( 'failing-log-processed' ) #NEWLINE# incr . assert_any_call ( 'failing-log-category-tag1' ) #NEWLINE# incr . assert_any_call ( 'failing-log-category-tag2' ) #NEWLINE# #UNINDENT# categorize_fn . assert_called_with ( 'project-slug' , fake_rules , '' . join ( chunks ) ) #NEWLINE# self . assertSetEqual ( tags_by_step [ step . id ] , { 'tag1' , 'tag2' } )