fix tests

This commit is contained in:
Mike Fährmann 2017-05-27 11:33:55 +02:00
parent 67791e1b36
commit f79320e35b
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 26 additions and 12 deletions

View File

@ -17,11 +17,11 @@ class DirectlinkExtractor(Extractor):
category = "directlink" category = "directlink"
directory_fmt = [] directory_fmt = []
filename_fmt = "{filename}" filename_fmt = "{filename}"
pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gifv?|webm|mp4)"] pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg)"]
test = [("https://i.imgur.com/21yMxCS.png", { test = [(("https://photos.smugmug.com/The-World/Hawaii/"
"url": "6f2dcfb86815bdd72808c313e5f715610bc7b9b2", "i-SWz2K6n/2/X3/IMG_0311-X3.jpg"), {
"keyword": "6a9636d8dd6f71f14d6d20d24153fc83a9895ed9", "url": "32ee1045881e17ef3f13a9958595afa42421ec6c",
"content": "0c8768055e4e20e7c7259608b67799171b691140", "keyword": "5bd7871a6957e1693c43abf31d7c0a38e39a81de",
})] })]
def __init__(self, match): def __init__(self, match):

View File

@ -39,8 +39,8 @@ class MangaparkChapterExtractor(Extractor):
r"([^/]+/s(\d+)(?:/v([^/]+))?/c(\d+)(?:([^/]+)|/e(\d+))?)")] r"([^/]+/s(\d+)(?:/v([^/]+))?/c(\d+)(?:([^/]+)|/e(\d+))?)")]
test = [ test = [
("http://mangapark.me/manga/gosu/s2/c55", { ("http://mangapark.me/manga/gosu/s2/c55", {
"url": "fefe84492d9118de5962563fbecb9362051c52d5", "url": "482d4a27c1e7f03cff8afac145d06f3ddeac82bb",
"keyword": "652b38c40bdfb5592456b6e7524a3acfdef9fae6", "keyword": "bd97ca24ef344b44292910384215ef3f1005ea2e",
}), }),
(("http://mangapark.me/manga/" (("http://mangapark.me/manga/"
"ad-astra-per-aspera-hata-kenjirou/s1/c1.2"), { "ad-astra-per-aspera-hata-kenjirou/s1/c1.2"), {

View File

@ -25,6 +25,6 @@ class YonkouprodMangaExtractor(foolslide.FoolslideMangaExtractor):
"""Extractor for manga from yonkouprod.com""" """Extractor for manga from yonkouprod.com"""
category = "yonkouprod" category = "yonkouprod"
pattern = foolslide.manga_pattern(r"(?:www\.)?yonkouprod\.com/reader") pattern = foolslide.manga_pattern(r"(?:www\.)?yonkouprod\.com/reader")
test = [("https://yonkouprod.com/reader/series/one-punch-man/", { test = [("https://yonkouprod.com/reader/series/attack-on-titan/", {
"url": "e17ed7a2098e2f18e50b64a28a810f62687d05e2", "url": "9d43602ad4a3a8cf65922bf106affa5a6b9523b1",
})] })]

View File

@ -20,6 +20,12 @@ TESTDATA_FMT = """
}})] }})]
""" """
TESTDATA_EXCEPTION_FMT = """
test = [("{}", {{
"exception": "{}",
}})]
"""
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--content", action="store_true") parser.add_argument("--content", action="store_true")
@ -39,10 +45,18 @@ def main():
config.load() config.load()
for url in urls: for url in urls:
tjob = job.TestJob(url, content=args.content) tjob = job.TestJob(url, content=args.content)
tjob.run() try:
tjob.run()
except Exception as exc:
fmt = TESTDATA_EXCEPTION_FMT
data = (exc.__class__.__name__,)
else:
fmt = TESTDATA_FMT
data = (tjob.hash_url.hexdigest(),
tjob.hash_keyword.hexdigest(),
tjob.hash_content.hexdigest())
print(tjob.extractor.__class__.__name__) print(tjob.extractor.__class__.__name__)
print(TESTDATA_FMT.format(url, tjob.hash_url.hexdigest(), print(fmt.format(url, *data))
tjob.hash_keyword.hexdigest(), tjob.hash_content.hexdigest()))
if __name__ == '__main__': if __name__ == '__main__':
main() main()