2013-02-18 18:59:16 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2014-01-05 15:50:57 +00:00
|
|
|
# Copyright (C) 2013-2014 Bastian Kleineidam
|
2015-04-18 10:34:33 +00:00
|
|
|
# Copyright (C) 2015 Tobias Gruetzmacher
|
2013-02-18 18:59:16 +00:00
|
|
|
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():
|
2013-04-26 04:53:14 +00:00
|
|
|
scraperobj = scraperclass()
|
|
|
|
scraperobj = scraperclass(indexes=["bla"])
|
|
|
|
self.assertTrue(scraperobj.url,
|
|
|
|
"missing url in %s" % scraperobj.getName())
|
2013-02-18 18:59:16 +00:00
|
|
|
|
|
|
|
def test_find_scraperclasses_single(self):
|
2015-04-18 10:34:33 +00:00
|
|
|
result = scraper.find_scraperclasses("xkcd")
|
2013-02-18 18:59:16 +00:00
|
|
|
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, "")
|