Fix scraperclass function. Closes issue #7.
This commit is contained in:
parent
ee8a0d66ee
commit
dc9334cca9
2 changed files with 25 additions and 1 deletions
|
@ -198,7 +198,7 @@ def find_scraperclasses(comic, multiple_allowed=False):
|
|||
if lname == cname:
|
||||
# perfect match
|
||||
if not multiple_allowed:
|
||||
return scraperclass
|
||||
return [scraperclass]
|
||||
else:
|
||||
candidates.append(scraperclass)
|
||||
elif cname in lname:
|
||||
|
|
24
tests/test_scraper.py
Normal file
24
tests/test_scraper.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2013 Bastian Kleineidam
|
||||
from unittest import TestCase
|
||||
from dosagelib import scraper
|
||||
|
||||
|
||||
class ScraperTester(TestCase):
|
||||
"""Test scraper module functions."""
|
||||
|
||||
def test_get_scraperclasses(self):
|
||||
for scraperclass in scraper.get_scraperclasses():
|
||||
scraperclass()
|
||||
scraperclass(indexes=["bla"])
|
||||
|
||||
def test_find_scraperclasses_single(self):
|
||||
result = scraper.find_scraperclasses("CalvinAndHobbes")
|
||||
self.assertEqual(len(result), 1)
|
||||
|
||||
def test_find_scraperclasses_multi(self):
|
||||
result = scraper.find_scraperclasses("a", multiple_allowed=True)
|
||||
self.assertTrue(len(result) > 1)
|
||||
|
||||
def test_find_scraperclasses_error(self):
|
||||
self.assertRaises(ValueError, scraper.find_scraperclasses, "")
|
Loading…
Reference in a new issue