mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
test archive-id creation and uniqueness
This commit is contained in:
parent
3cec533c28
commit
be3ea4425d
@ -344,8 +344,10 @@ class TestJob(DownloadJob):
|
|||||||
self.content = content
|
self.content = content
|
||||||
self.list_url = []
|
self.list_url = []
|
||||||
self.list_keyword = []
|
self.list_keyword = []
|
||||||
|
self.list_archive = []
|
||||||
self.hash_url = hashlib.sha1()
|
self.hash_url = hashlib.sha1()
|
||||||
self.hash_keyword = hashlib.sha1()
|
self.hash_keyword = hashlib.sha1()
|
||||||
|
self.hash_archive = hashlib.sha1()
|
||||||
self.hash_content = hashlib.sha1()
|
self.hash_content = hashlib.sha1()
|
||||||
if content:
|
if content:
|
||||||
self.fileobj = self.HashIO(self.hash_content)
|
self.fileobj = self.HashIO(self.hash_content)
|
||||||
@ -358,6 +360,7 @@ class TestJob(DownloadJob):
|
|||||||
def handle_url(self, url, keywords):
|
def handle_url(self, url, keywords):
|
||||||
self.update_url(url)
|
self.update_url(url)
|
||||||
self.update_keyword(keywords)
|
self.update_keyword(keywords)
|
||||||
|
self.update_archive(keywords)
|
||||||
self.update_content(url)
|
self.update_content(url)
|
||||||
|
|
||||||
def handle_urllist(self, urls, keywords):
|
def handle_urllist(self, urls, keywords):
|
||||||
@ -382,6 +385,12 @@ class TestJob(DownloadJob):
|
|||||||
self.hash_keyword.update(
|
self.hash_keyword.update(
|
||||||
json.dumps(kwdict, sort_keys=True).encode())
|
json.dumps(kwdict, sort_keys=True).encode())
|
||||||
|
|
||||||
|
def update_archive(self, kwdict):
|
||||||
|
"""Update the archive-id hash"""
|
||||||
|
archive_id = self.extractor.archive_fmt.format_map(kwdict)
|
||||||
|
self.list_archive.append(archive_id)
|
||||||
|
self.hash_archive.update(archive_id.encode())
|
||||||
|
|
||||||
def update_content(self, url):
|
def update_content(self, url):
|
||||||
"""Update the content hash"""
|
"""Update the content hash"""
|
||||||
if self.content:
|
if self.content:
|
||||||
|
@ -68,6 +68,10 @@ class TestExtractors(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
# test archive-id uniqueness
|
||||||
|
self.assertEqual(len(set(tjob.list_archive)), len(tjob.list_archive))
|
||||||
|
|
||||||
|
# test extraction results
|
||||||
if "url" in result:
|
if "url" in result:
|
||||||
self.assertEqual(result["url"], tjob.hash_url.hexdigest())
|
self.assertEqual(result["url"], tjob.hash_url.hexdigest())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user