2016-03-07 00:08:57 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-01-05 15:50:57 +00:00
|
|
|
# Copyright (C) 2013-2014 Bastian Kleineidam
|
2016-03-07 00:08:57 +00:00
|
|
|
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
|
|
|
|
|
|
|
import pytest
|
2013-02-18 18:59:16 +00:00
|
|
|
from dosagelib import scraper
|
|
|
|
|
|
|
|
|
2016-03-07 00:08:57 +00:00
|
|
|
class TestScraper(object):
|
2013-02-18 18:59:16 +00:00
|
|
|
"""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"])
|
2016-03-07 00:08:57 +00:00
|
|
|
assert 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")
|
2016-03-07 00:08:57 +00:00
|
|
|
assert len(result) == 1
|
2013-02-18 18:59:16 +00:00
|
|
|
|
|
|
|
def test_find_scraperclasses_multi(self):
|
|
|
|
result = scraper.find_scraperclasses("a", multiple_allowed=True)
|
2016-03-07 00:08:57 +00:00
|
|
|
assert len(result) > 1
|
2013-02-18 18:59:16 +00:00
|
|
|
|
|
|
|
def test_find_scraperclasses_error(self):
|
2016-03-07 00:08:57 +00:00
|
|
|
with pytest.raises(ValueError):
|
|
|
|
scraper.find_scraperclasses("")
|