Fix comic test with zero strip images.

This commit is contained in:
Bastian Kleineidam 2013-03-19 20:45:45 +01:00
parent 17fe58b864
commit ea4a59318f

View file

@ -75,20 +75,25 @@ class _ComicTester(TestCase):
if num > 0 and self.scraperclass.prevUrlMatchesStripUrl: if num > 0 and self.scraperclass.prevUrlMatchesStripUrl:
self.check_stripurl(strip) self.check_stripurl(strip)
num += 1 num += 1
if self.scraperclass.prevSearch and not scraperobj.hitFirstStripUrl: if self.scraperclass.prevSearch:
self.check(num >= 4, 'traversal failed after %d strips, check the prevSearch pattern at %s.' % (num, strip.stripUrl)) self.check(num > 0, 'no strips found')
# Check that exactly or for multiple pages at least 5 images are saved. if not scraperobj.hitFirstStripUrl:
# This is different than the image number check above since it checks saved files, self.check_scraperesult(max_strips, num, strip, scraperobj)
# ie. it detects duplicate filenames.
saved_images = self.get_saved_images() def check_scraperesult(self, max_strips, num, strip, scraperobj):
num_images = len(saved_images) self.check(num >= 4, 'traversal failed after %d strips, check the prevSearch pattern at %s.' % (num, strip.stripUrl))
# subtract the number of skipped URLs with no image from the expected image number # Check that exactly or for multiple pages at least 5 images are saved.
num_images_expected = max_strips - len(scraperobj.skippedUrls) # This is different than the image number check above since it checks saved files,
attrs = (num_images, saved_images, num_images_expected, self.tmpdir) # ie. it detects duplicate filenames.
if self.scraperclass.multipleImagesPerStrip: saved_images = self.get_saved_images()
self.check(num_images >= num_images_expected, 'saved %d %s instead of at least %d images in %s' % attrs) num_images = len(saved_images)
else: # subtract the number of skipped URLs with no image from the expected image number
self.check(num_images == num_images_expected, 'saved %d %s instead of %d images in %s' % attrs) num_images_expected = max_strips - len(scraperobj.skippedUrls)
attrs = (num_images, saved_images, num_images_expected, self.tmpdir)
if self.scraperclass.multipleImagesPerStrip:
self.check(num_images >= num_images_expected, 'saved %d %s instead of at least %d images in %s' % attrs)
else:
self.check(num_images == num_images_expected, 'saved %d %s instead of %d images in %s' % attrs)
def check_stripurl(self, strip): def check_stripurl(self, strip):
if not self.scraperclass.stripUrl: if not self.scraperclass.stripUrl: