#NEWLINE# @ patch . object ( CoverageHandler , 'get_coverage' ) #NEWLINE# @ patch . object ( CoverageHandler , 'process_diff' ) #NEWLINE# def test_process( self , process_diff , get_coverage ) : #NEWLINE# #INDENT# project = self . create_project ( ) #NEWLINE# build = self . create_build ( project ) #NEWLINE# job = self . create_job ( build ) #NEWLINE# jobphase = self . create_jobphase ( job ) #NEWLINE# jobstep = self . create_jobstep ( jobphase ) #NEWLINE# handler = CoverageHandler ( jobstep ) #NEWLINE# process_diff . return_value = { #NEWLINE# #INDENT# 'setup.py' : set ( [ 1 , 2 , 3 , 4 , 5 ] ) , #NEWLINE# 'config.py' : set ( [ 1 , 3 ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# get_coverage . return_value = [ FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'setup.py' , data = 'CUNNNNCCNNNUNNNUUUUUU' ) , FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'config.py' , data = '' ) ] #NEWLINE# fp = StringIO ( ) #NEWLINE# handler . process ( fp ) #NEWLINE# get_coverage . assert_called_once_with ( fp ) #NEWLINE# get_coverage . reset_mock ( ) #NEWLINE# get_coverage . return_value = [ FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'setup.py' , data = 'NUUNNNNNNNNUCCNU' ) , FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'config.py' , data = 'U' ) ] #NEWLINE# fp = StringIO ( ) #NEWLINE# handler . process ( fp ) #NEWLINE# get_coverage . assert_called_once_with ( fp ) #NEWLINE# get_coverage . reset_mock ( ) #NEWLINE# get_coverage . return_value = [ FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'setup.py' , data = 'NUUNNNNNNNNUCCNU' ) , FileCoverage ( job_id = job . id , step_id = jobstep . id , project_id = project . id , filename = 'config.py' , data = 'NNC' ) ] #NEWLINE# fp = StringIO ( ) #NEWLINE# handler . process ( fp ) #NEWLINE# get_coverage . assert_called_once_with ( fp ) #NEWLINE# file_cov = list ( FileCoverage . query . filter ( ( FileCoverage . job_id == job . id ) ) ) #NEWLINE# assert ( len ( file_cov ) == 2 ) #NEWLINE# file_cov . sort ( key = ( lambda r : ( - len ( r . data ) ) ) ) #NEWLINE# assert ( file_cov [ 0 ] . filename == 'setup.py' ) #NEWLINE# assert ( file_cov [ 0 ] . data == 'CUUNNNCCNNNUCCNUUUUUU' ) #NEWLINE# assert ( file_cov [ 0 ] . lines_covered == 5 ) #NEWLINE# assert ( file_cov [ 0 ] . lines_uncovered == 9 ) #NEWLINE# assert ( fp [ 0 ] . diff_lines_covered == 1 ) #NEWLINE# assert ( file_cov [ 0 ] . diff_lines_uncovered == 2 ) #NEWLINE# assert ( file_cov [ 1 ] . filename == 'config.py' ) #NEWLINE# assert ( file_cov [ 1 ] . data == 'UNC' ) #NEWLINE# assert ( file_cov [ 1 ] . lines_covered == 1 ) #NEWLINE# assert ( file_cov [ 1 ] . lines_uncovered == 1 ) #NEWLINE# assert ( file_cov [ 1 ] . diff_lines_covered == 1 ) #NEWLINE# assert ( file_cov [ 1 ] . diff_lines_uncovered == 1 )