mirror of
https://github.com/simon987/Simple-Incremental-Search-Tool.git
synced 2025-12-13 23:29:04 +00:00
Added thumbnail generator
This commit is contained in:
@@ -12,10 +12,10 @@ class CrawlerTest(TestCase):
|
||||
|
||||
c.crawl("test_folder")
|
||||
|
||||
self.assertEqual(len(c.documents), 28)
|
||||
self.assertEqual(len(c.documents), 31)
|
||||
|
||||
def test_file_count(self):
|
||||
|
||||
c = Crawler([])
|
||||
|
||||
self.assertEqual(c.countFiles("test_folder"), 28)
|
||||
self.assertEqual(c.countFiles("test_folder"), 31)
|
||||
|
||||
@@ -2,6 +2,7 @@ from unittest import TestCase
|
||||
from thumbnail import ThumbnailGenerator
|
||||
from PIL import Image
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
class ThumbnailGeneratorTest(TestCase):
|
||||
@@ -22,3 +23,35 @@ class ThumbnailGeneratorTest(TestCase):
|
||||
if os.path.isfile("test_thumb1.jpg"):
|
||||
os.remove("test_thumb1.jpg")
|
||||
|
||||
def test_generate_all(self):
|
||||
shutil.rmtree("test_thumbnails")
|
||||
|
||||
generator = ThumbnailGenerator(300)
|
||||
|
||||
docs = [{'_source': {'path': 'test_folder', 'name': 'books.csv'}, '_id': 'books.csv-ID'},
|
||||
{'_source': {'path': 'test_folder', 'name': 'sample_3.jpg'}, '_id': 'sample_3.jpg-ID'},
|
||||
{'_source': {'path': 'test_folder', 'name': 'sample_5.png'}, '_id': 'sample_5.png-ID'},
|
||||
{'_source': {'path': 'test_folder', 'name': 'sample_6.gif'}, '_id': 'sample_6.gif-ID'},
|
||||
{'_source': {'path': 'test_folder', 'name': 'sample_7.bmp'}, '_id': 'sample_7.bmp-ID'},
|
||||
{'_source': {'path': 'test_folder', 'name': 'sample_2.jpeg'}, '_id': 'sample_2.jpeg-ID'}]
|
||||
|
||||
generator.generate_all(docs, "test_thumbnails")
|
||||
|
||||
self.assertFalse(os.path.isfile("test_thumbnails/books.csv-ID") and
|
||||
os.path.getsize("test_thumbnails/books.csv-ID") > 0)
|
||||
self.assertTrue(os.path.isfile("test_thumbnails/sample_3.jpg-ID") and
|
||||
os.path.getsize("test_thumbnails/sample_3.jpg-ID") > 0)
|
||||
self.assertTrue(os.path.isfile("test_thumbnails/sample_2.jpeg-ID") and
|
||||
os.path.getsize("test_thumbnails/sample_2.jpeg-ID") > 0)
|
||||
self.assertTrue(os.path.isfile("test_thumbnails/sample_5.png-ID") and
|
||||
os.path.getsize("test_thumbnails/sample_5.png-ID") > 0)
|
||||
self.assertTrue(os.path.isfile("test_thumbnails/sample_6.gif-ID") and
|
||||
os.path.getsize("test_thumbnails/sample_6.gif-ID") > 0)
|
||||
self.assertTrue(os.path.isfile("test_thumbnails/sample_7.bmp-ID") and
|
||||
os.path.getsize("test_thumbnails/sample_7.bmp-ID") > 0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
spec/test_folder/sample_5.png
vendored
Normal file
BIN
spec/test_folder/sample_5.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
spec/test_folder/sample_6.gif
vendored
Normal file
BIN
spec/test_folder/sample_6.gif
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
spec/test_folder/sample_7.bmp
vendored
Normal file
BIN
spec/test_folder/sample_7.bmp
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
Reference in New Issue
Block a user