#NEWLINE# @ mock . patch ( 'requests.get' ) #NEWLINE# @ pytest . mark . django_db #NEWLINE# def test_download_file_missing_content_length( requests_mock ) : #NEWLINE# #INDENT# file_data = six . b ( 'My cool package' ) #NEWLINE# release_file = ReleaseFileFactory ( distribution = None , md5_digest = md5 ( file_data ) . hexdigest ( ) ) #NEWLINE# requests_mock . return_value = mock . Mock ( ** { #NEWLINE# #INDENT# 'headers' : { #NEWLINE# #INDENT# 'content-type' : 'application/octet-stream' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'content' : file_data , #NEWLINE# #UNINDENT# } ) #NEWLINE# tasks . download_file . run ( release_file . pk ) #NEWLINE# release_file = models . ReleaseFile . objects . get ( pk = release_file . pk ) #NEWLINE# assert ( release_file . distribution . read ( ) == file_data ) #NEWLINE# assert ( release_file . distribution . size == len ( file_data ) ) #NEWLINE# assert ( release_file . distribution . name == 'default/2.7/t/test-package/test-1.0.0-sdist.zip' )