def test_headers(self): cdisp = ('attachment;filename="hello.zip";' 'filename*=UTF-8\'\'hello.zip') resp = _FakeResponse('http://foo.bar/baz.zip', b'content', headers={ 'content-disposition': cdisp, }) res = downloader._get_filename(resp) self.assertEqual(res, 'hello.zip')
def test_filename_from_headers( content_disposition: Optional[str], filename: Optional[str], ): if content_disposition: headers = { 'content-disposition': content_disposition, } else: headers = None resp = _FakeResponse('http://foo.bar/baz.zip', b'content', headers=headers) assert downloader._get_filename(resp), filename
def test_no_headers(self): resp = _FakeResponse('http://foo.bar/baz.zip', b'content') res = downloader._get_filename(resp) self.assertEqual(res, 'baz.zip')