def test_download_interrupted(self): download = Download(output_file=open(os.devnull, 'w')) download.start( Response(url=httpbin('/'), headers={'Content-Length': 5})) download.chunk_downloaded(b'1234') download.finish() self.assertTrue(download.interrupted)
def test_download_no_Content_Length(self): download = Download(output_file=open(os.devnull, 'w')) download.start(Response(url=httpbin('/'))) time.sleep(1.1) download.chunk_downloaded(b'12345') download.finish() self.assertFalse(download.interrupted)
def test_download_interrupted(self, httpbin): devnull = open(os.devnull, 'w') download = Download(output_file=devnull, progress_file=devnull) download.start( Response(url=httpbin.url + '/', headers={'Content-Length': 5})) download.chunk_downloaded(b'1234') download.finish() assert download.interrupted
def test_download_no_Content_Length(self, httpbin): devnull = open(os.devnull, 'w') download = Download(output_file=devnull, progress_file=devnull) download.start(Response(url=httpbin.url + '/')) time.sleep(1.1) download.chunk_downloaded(b'12345') download.finish() assert not download.interrupted
def test_download_interrupted(self): download = Download(output_file=open(os.devnull, 'w')) download.start(Response( url=httpbin('/'), headers={'Content-Length': 5} )) download.chunk_downloaded(b'1234') download.finish() self.assertTrue(download.interrupted)
def test_download_interrupted(self, httpbin): devnull = open(os.devnull, 'w') download = Download(output_file=devnull, progress_file=devnull) download.start(Response( url=httpbin.url + '/', headers={'Content-Length': 5} )) download.chunk_downloaded(b'1234') download.finish() assert download.interrupted
def test_download_with_Content_Length(self): devnull = open(os.devnull, 'w') download = Download(output_file=devnull, progress_file=devnull) download.start( Response(url=httpbin('/'), headers={'Content-Length': 10})) time.sleep(1.1) download.chunk_downloaded(b'12345') time.sleep(1.1) download.chunk_downloaded(b'12345') download.finish() assert not download.interrupted
def test_download_with_Content_Length(self): devnull = open(os.devnull, 'w') download = Download(output_file=devnull, progress_file=devnull) download.start(Response( url=httpbin('/'), headers={'Content-Length': 10} )) time.sleep(1.1) download.chunk_downloaded(b'12345') time.sleep(1.1) download.chunk_downloaded(b'12345') download.finish() assert not download.interrupted