def _test_05_video_resizing(self): ''' check if videos are resized properly ''' #useTestFlavorsConf() - had to remove that and test on standard flavors only deleteAllThumbnails() tumbler = Tumbler() tumbler.setQuitOnError() video = ["file:///usr/share/tumbler-tests/data/size_352x288.mp4"] mime = ["video/mp4"] flavors = getFlavorsList() original_size = 352, 288 for flavor in flavors: tumbler.simple_Queue(video, mime, flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(video[0], flavor) #print "Should generated thumbnail:", thumbnails # check if those thumbnails exists self.assertEqual(areFilesExist(thumbnails), True, 'Thumbnail has not been created!') # check if files are 'readable' as a image and do not have zero size self.assertEqual(areFilesProperImages(thumbnails), True, 'Not all thumbnails are proper image files!') # get size of the image size = getImageSize(thumbnails[0]) # calculate proper size for a thumbnail targetSize = calculateSizeSrcFlavor(original_size, flavor) #print "Orig:(", original_size, ") Min:(", getFlavorMinSize(flavor), ") Dst:(", getFlavorSize(flavor), ") -> (", targetSize, ")" # check if thumbnail has proper size self.assertEqual(size, targetSize)
def _test_05_video_resizing(self): ''' check if videos are resized properly ''' #useTestFlavorsConf() - had to remove that and test on standard flavors only deleteAllThumbnails() tumbler = Tumbler() tumbler.setQuitOnError() video = [ "file:///usr/share/tumbler-tests/data/size_352x288.mp4" ] mime = [ "video/mp4" ] flavors = getFlavorsList() original_size = 352, 288 for flavor in flavors: tumbler.simple_Queue(video, mime, flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(video[0], flavor) #print "Should generated thumbnail:", thumbnails # check if those thumbnails exists self.assertEqual(areFilesExist( thumbnails ), True, 'Thumbnail has not been created!') # check if files are 'readable' as a image and do not have zero size self.assertEqual(areFilesProperImages( thumbnails ), True, 'Not all thumbnails are proper image files!') # get size of the image size = getImageSize(thumbnails[0]) # calculate proper size for a thumbnail targetSize = calculateSizeSrcFlavor(original_size, flavor) #print "Orig:(", original_size, ") Min:(", getFlavorMinSize(flavor), ") Dst:(", getFlavorSize(flavor), ") -> (", targetSize, ")" # check if thumbnail has proper size self.assertEqual(size, targetSize)
def test_04_check_flavors_resizing(self): ''' check if thumbnails have proper sizes for every input size of the image ''' uri = "file:///home/" + user() + "/MyDocs/.images/image.png" # use png due to some problems with really small (like 1x1) jpeg images in python-imaging mime = "image/png" all_thumbs = getThumbnailFilepaths(uri) sizes = [ (1,1), (2,2), (1,1000), (1000,1), (20,50), (1000, 1000), (10,10), (3000, 3000), (4000, 3000), (5,1000), (1000,5)] for flavor in getFlavorsList(): for size in sizes: deleteFiles(uri) thumb_name = createImageExt(name=uri, mime=mime, width=size[0], height=size[1], strings=["test_04_check_flavors_resizing"]) # this thumbnail should be created thumb_path = getThumbnailFlavorPath(uri, flavor)[0] deleteFiles(all_thumbs) deleteFiles(thumb_path) tumbler = Tumbler() tumbler.simple_Queue([uri], [mime], flavor) target_size = calculateSizeSrcFlavor(size, flavor) errorMsg = "Orig:" + str(size) + " Min:" + str(getFlavorMinSize(flavor)) + " Dst:" + str(getFlavorSize(flavor)) + " -> should_be" + str(target_size) + " == is" + str(getImageSize(thumb_path)) self.assertEqual(areFilesExist(thumb_path), True, 'Thumbnail for proper flavor was not created! ' + thumb_path + ' should be created.') self.assertEqual(getImageSize(thumb_path), target_size, 'Image does not have a proper size for flavor ' + flavor + ':' + errorMsg) self.assertEqual(tumbler.readySignalCount(), 1, 'Wrong number of Ready signal') self.assertEqual(tumbler.errorSignalCount(), 0, 'Wrong number of Error signal') self.assertEqual(tumbler.readyItemsCount(), 1, 'Wrong number of Ready items') # cleanup deleteFiles(all_thumbs) deleteFiles(uri) deleteFiles(thumb_path)
def test_03_check_flavors_sizes(self): ''' check if thumbnails have proper size for particular flavors ''' uri = "file:///home/" + user() + "/MyDocs/.images/image.jpeg" mime = "image/jpeg" thumb_name = createImageExt(name=uri, width=300, height=560, strings=["test_03_check_flavors_sizes"]) all_thumbs = getThumbnailFilepaths(uri) for flavor in getFlavorsList(): ''' ''' # this thumbnail should be created thumb_path = getThumbnailFlavorPath(uri, flavor)[0] deleteFiles(all_thumbs) tumbler = Tumbler() tumbler.simple_Queue([uri], [mime], flavor) target_size = calculateSizeSrcFlavor((300, 560), flavor) self.assertEqual(areFilesExist(thumb_path), True, 'Thumbnail for proper flavor was not created! ' + thumb_path + ' should be created.') self.assertEqual(getImageSize(thumb_path), target_size, 'Image does not have a proper size for flavor ' + flavor + ': is ' + str(getImageSize(thumb_path)) + ' and should be ' + str(target_size)) self.assertEqual(tumbler.readySignalCount(), 1, 'Wrong number of Ready signal') self.assertEqual(tumbler.errorSignalCount(), 0, 'Wrong number of Error signal') self.assertEqual(tumbler.readyItemsCount(), 1, 'Wrong number of Ready items') deleteFiles(thumb_path) # cleanup deleteFiles(all_thumbs) deleteFiles(uri)
def test_02_check_flavors_multiple_files(self): ''' check if thumbnails are generated for proper flavor when requesting multiple files ''' uri = [ "file:///home/" + user() + "/MyDocs/.images/image_01.jpeg", "file:///home/" + user() + "/MyDocs/.images/image_02.png", "file:///home/" + user() + "/MyDocs/.images/image_03.gif" ] mime = ["image/jpeg", "image/png", "image/gif"] thumb_name = [ createImageExt(name=uri[0], mime=mime[0], width=800, height=480, strings=["test_01_check_flavors_multiple"]), createImageExt(name=uri[1], mime=mime[1], width=800, height=480, strings=["test_01_check_flavors_multiple"]), createImageExt(name=uri[2], mime=mime[2], width=800, height=480, strings=["test_01_check_flavors_multiple"]) ] all_thumbs = getThumbnailFilepaths(uri) for flavor in getFlavorsList(): ''' ''' # this thumbnails should be created thumb_path = getThumbnailFlavorPath(uri, flavor) deleteFiles(all_thumbs) tumbler = Tumbler() tumbler.simple_Queue(uri, mime, flavor) self.assertEqual(areFilesExist(thumb_path), True, 'Thumbnail for proper flavor was not created!') self.assertEqual(tumbler.readyItemsCount(), 3, 'Wrong number of Ready items') self.assertEqual(tumbler.errorItemsCount(), 0, 'Wrong number of Error items') #cleanup deleteFiles(all_thumbs) deleteFiles(uri)
def _test_04_mpeg_format_insignificant(self): ''' check if MPEG videos are properly thumbnailed ''' videos = self.getAllVideosWithFormat("mpeg") flavor = "normal" mime = [] for tmp in videos: mime.append("video/mpeg") tumbler = Tumbler() tumbler.setQuitOnError() tumbler.simple_Queue(videos, mime, flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(videos, flavor) # check if those thumbnails exists self.assertEqual(areFilesExist( thumbnails ), True, 'Not all thumbnails were created for MPEG videos!') # cleanup deleteAllThumbnails()
def test_03_check_background(self): ''' check if thumbnails are generated for background scheduler ''' uri = "file:///home/" + user() + "/MyDocs/.images/image.jpeg" mime = "image/jpeg" deleteFiles(uri) thumb_name = createImageExt(name=uri, width=200, height=200, strings=["test_03_check_background"]) all_thumbs = getThumbnailFilepaths(uri) # cleanup before test deleteFiles(all_thumbs) for flavor in getFlavorsList(): ''' ''' # this thumbnail should be created thumb_path = getThumbnailFlavorPath(uri, flavor)[0] deleteFiles(all_thumbs) tumbler = Tumbler() tumbler.simple_Queue([uri], [mime], flavor, "background") self.assertEqual( areFilesExist(thumb_path), True, 'Thumbnail for scheduler background was not created!') self.assertEqual( tumbler.readySignalCount(), 1, 'Wrong number of Ready signal: ' + str(tumbler.readySignalCount())) self.assertEqual( tumbler.errorSignalCount(), 0, 'Wrong number of Error signal: ' + str(tumbler.errorSignalCount())) self.assertEqual( tumbler.readyItemsCount(), 1, 'Wrong number of Ready items: ' + str(tumbler.readyItemsCount()) + ' Items: ' + str(tumbler.signal_ready)) deleteFiles(thumb_path) # cleanup deleteFiles(all_thumbs) deleteFiles(uri)
def _test_04_mpeg_format_insignificant(self): ''' check if MPEG videos are properly thumbnailed ''' videos = self.getAllVideosWithFormat("mpeg") flavor = "normal" mime = [] for tmp in videos: mime.append("video/mpeg") tumbler = Tumbler() tumbler.setQuitOnError() tumbler.simple_Queue(videos, mime, flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(videos, flavor) # check if those thumbnails exists self.assertEqual(areFilesExist(thumbnails), True, 'Not all thumbnails were created for MPEG videos!') # cleanup deleteAllThumbnails()
def test_02_png_format(self): ''' check if PNG images are properly thumbnailed ''' flavor = "normal" data = [ [ addFileSchema(self.dataDir + "image_01.png"), addFileSchema(self.dataDir + "image_02.png"), addFileSchema(self.dataDir + "image_03.png"), addFileSchema(self.dataDir + "image_04.png"), ], [ "image/png", "image/png", "image/png", "image/png", ], [ (100, 100), (450, 450), (800, 480), (15, 15), ], ] for i in range(len(data[0])): # creating images createImageExt(name=data[0][i], mime=data[1][i], width=data[2][i][0], height=data[2][i][1], strings=["test_02_png_format"]) # ask for thumbnails tumbler = Tumbler() tumbler.simple_Queue(data[0], data[1], flavor=flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(data[0], flavor) # check if those thumbnails exists self.assertEqual(areFilesExist(thumbnails), True, 'Not all thumbnails were created for PNG images!') # check if files are 'readable' as a image and do not have zero size self.assertEqual(areFilesProperImages(thumbnails), True, 'Not all thumbnails are proper image files!')
def test_05_check_foreground_signal_count(self): ''' check if Tumbler sends more than one one Ready signal for foreground scheduler ''' # first create lots of images to pass to Tumbler flavor = "normal" uris = [] thumbs = [] mimes = [] for i in range(100): uri = "file:///home/" + user() + "/MyDocs/.images/image_" + str( i) + ".jpeg" uris.append(uri) mimes.append("image/jpeg") deleteFiles(uri) createImageExt(name=uri, width=110, height=110, strings=[ "test_04_check_background_signal_count(" + str(i) + ")" ]) thumbs.append(getThumbnailFlavorPath(uri, flavor)[0]) # make sure that thumbnails do not exist deleteFiles(thumbs) # make a request with backround scheduler tumbler = Tumbler() tumbler.setLogLevel(2) tumbler.simple_Queue(uris, mimes, flavor, "foreground") self.assertNotEqual( tumbler.readySignalCount(), 1, 'Wrong number of Ready signal: ' + str(tumbler.readySignalCount())) self.assertEqual( tumbler.readyItemsCount(), 100, 'Wrong number of Ready items: ' + str(tumbler.readyItemsCount())) # clean up deleteFiles(uris) deleteFiles(thumbs)
def test_02_png_format(self): ''' check if PNG images are properly thumbnailed ''' flavor = "normal" data = [ [ addFileSchema(self.dataDir + "image_01.png"), addFileSchema(self.dataDir + "image_02.png"), addFileSchema(self.dataDir + "image_03.png"), addFileSchema(self.dataDir + "image_04.png"), ], [ "image/png", "image/png", "image/png", "image/png", ], [ (100, 100), (450, 450), (800, 480), (15, 15), ], ] for i in range(len(data[0])): # creating images createImageExt(name=data[0][i], mime=data[1][i], width=data[2][i][0], height=data[2][i][1], strings=["test_02_png_format"]) # ask for thumbnails tumbler = Tumbler() tumbler.simple_Queue(data[0], data[1], flavor=flavor) # get list of thumbnails which should be created thumbnails = getThumbnailFlavorPath(data[0], flavor) # check if those thumbnails exists self.assertEqual(areFilesExist( thumbnails ), True, 'Not all thumbnails were created for PNG images!') # check if files are 'readable' as a image and do not have zero size self.assertEqual(areFilesProperImages( thumbnails ), True, 'Not all thumbnails are proper image files!')
def test_01_check_flavors(self): ''' check if thumbnails are generated for proper flavor ''' uri = "file:///home/" + user() + "/MyDocs/.images/image.jpeg" mime = "image/jpeg" thumb_name = createImageExt(name=uri, width=800, height=480, strings=["test_01_check_flavors"]) all_thumbs = getThumbnailFilepaths(uri) for flavor in getFlavorsList(): ''' ''' # this thumbnail should be created thumb_path = getThumbnailFlavorPath(uri, flavor)[0] deleteFiles(all_thumbs) tumbler = Tumbler() tumbler.simple_Queue([uri], [mime], flavor) self.assertEqual(areFilesExist(thumb_path), True, 'Thumbnail for proper flavor was not created! ' + thumb_path + ' should be created.') self.assertEqual(tumbler.readySignalCount(), 1, 'Wrong number of Ready signal') self.assertEqual(tumbler.errorSignalCount(), 0, 'Wrong number of Error signal') self.assertEqual(tumbler.readyItemsCount(), 1, 'Wrong number of Ready items') # cleanup deleteFiles(all_thumbs) deleteFiles(uri)