#NEWLINE# @ pytest . mark . parametrize ( 'with_signature' , [ True , False ] ) #NEWLINE# def test_redirects_to_real_file_url( self , db_request , with_signature ) : #NEWLINE# #INDENT# project = ProjectFactory . create ( ) #NEWLINE# release = ReleaseFactory . create ( project = project ) #NEWLINE# file_ = FileFactory . create ( release = release , filename = '{}-{}.tar.gz' . format ( project . name , release . version ) , python_version = 'source' , size = 27 , has_signature = with_signature ) #NEWLINE# expected_filename = ( file_ . filename if ( not with_signature ) else ( file_ . filename + '.asc' ) ) #NEWLINE# db_request . matchdict [ 'path' ] = 'source/{}/{}/{}' . format ( project . name [ 0 ] , project . name , expected_filename ) #NEWLINE# @ pretend . call_recorder #NEWLINE# def route_path( name , path ) : #NEWLINE# #INDENT# path = ( '/packages/ab/ab/thisisahash/' + file_ . filename ) #NEWLINE# if with_signature : #NEWLINE# #INDENT# path += '.asc' #NEWLINE# #UNINDENT# return path #NEWLINE# #UNINDENT# db_request . route_path = route_path #NEWLINE# resp = file_redirect ( db_request ) #NEWLINE# assert isinstance ( resp , HTTPTemporaryRedirect ) #NEWLINE# assert ( resp . headers [ 'Location' ] == ( '/packages/ab/ab/thisisahash/' + expected_filename ) ) #NEWLINE# assert ( route_path . calls == [ pretend . call ( 'packaging.file' , path = ( file_ . path if ( not with_signature ) else file_ . pgp_path ) ) ] )