def get_test_scrapers(): """Return scrapers that should be tested.""" if 'TESTALL' in os.environ: # test all comics (this will take some time) # ignore mangadex for now (site is temporary down) scraper_pattern = '^(?!MangaDex)' elif 'TESTCOMICS' in os.environ: scraper_pattern = os.environ['TESTCOMICS'] else: # Get limited number of scraper tests as default testscrapernames = [ # "classic" _BasicScraper 'AbstruseGoose', # complex _ParserScraper 'GoComics/CalvinAndHobbes', # _WordPressScraper 'GrrlPower', ] scraper_pattern = '^(' + '|'.join(testscrapernames) + ')$' matcher = re.compile(scraper_pattern) return [ scraperobj for scraperobj in scrapers.get() if matcher.match(scraperobj.name) ]
def get_used_languages(): languages = {} for scraperobj in scrapers.get(): lang = scraperobj.lang if lang not in languages: languages[lang] = scraperobj.language() return languages
def test_renamed(self): for scraperobj in scrapers.get(include_removed=True): if not isinstance(scraperobj, old.Renamed): continue assert len(scraperobj.getDisabledReasons()) > 0 # Renamed scraper should only point to an non-disabled scraper newscraper = scrapers.find(scraperobj.newname)[0] assert len(newscraper.getDisabledReasons()) == 0
def test_names(self): for scraperobj in scrapers.get(): name = scraperobj.name assert name.count('/') <= 1 if '/' in name: comicname = name.split('/')[1] else: comicname = name assert re.sub("[^0-9a-zA-Z_]", "", comicname) == comicname
def find_dups(self, name): """Check if comic name already exists.""" names = [(tmpl % name).lower() for tmpl in self.dup_templates] if names: for scraperobj in scrapers.get(): lname = scraperobj.name.lower() if lname in names: return scraperobj.name return None
def get_test_scrapers(): """Return scrapers that should be tested.""" if "TESTALL" in os.environ: # test all comics (this will take some time) return scrapers.get() if 'TESTCOMICS' in os.environ: scraper_pattern = re.compile(os.environ['TESTCOMICS']) else: # Get limited number of scraper tests as default testscrapernames = [ # "classic" _BasicScraper 'AbstruseGoose', # complex _ParserScraper 'GoComics/CalvinAndHobbes', # _WordPressScraper 'GrrlPower', ] scraper_pattern = re.compile('^(' + '|'.join(testscrapernames) + ')$') return [ scraperobj for scraperobj in scrapers.get() if scraper_pattern.match(scraperobj.name) ]
def test_user_dir(self): oldlen = len(scrapers.get()) scrapers.adddir(Path(__file__).parent / 'mocks' / 'extra') assert len(scrapers.get()) == oldlen + 1 assert len(scrapers.find('AnotherDummyTestScraper')) == 1
def test_get_scrapers(self): for scraperobj in scrapers.get(): scraperobj.indexes = ["bla"] assert scraperobj.url, "missing url in %s" % scraperobj.name