~khwalker/entertainer/config-keybindings

« back to all changes in this revision

Viewing changes to entertainerlib/tests/test_videothumbnailer.py

The thumbnailers have all been consolidated into a single module.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
'''Tests VideoThumbnailer'''
2
 
# pylint: disable-msg=W0212
3
 
 
4
 
import os
5
 
 
6
 
from entertainerlib.tests import EntertainerTest
7
 
from entertainerlib.utils.video_thumbnailer import VideoThumbnailer
8
 
from entertainerlib.utils.thumbnailer import ThumbnailerException
9
 
 
10
 
THIS_DIR = os.path.dirname(__file__)
11
 
 
12
 
class VideoThumbnailerTest(EntertainerTest):
13
 
    '''Tests VideoThumbnailer'''
14
 
 
15
 
    def setUp(self):
16
 
        """See unittest.TestCase"""
17
 
        EntertainerTest.setUp(self)
18
 
        self.debug = False
19
 
 
20
 
    def tearDown(self):
21
 
        """Clean up after the test"""
22
 
        EntertainerTest.tearDown(self)
23
 
 
24
 
    def testThumbnailerConstructor(self):
25
 
        '''Tests instantiation of thumbnailer class'''
26
 
        self.thumbnailer = VideoThumbnailer(
27
 
            THIS_DIR + '/data/VideoThumbnailer/test.avi', src='video')
28
 
        self.assertTrue(isinstance(self.thumbnailer, VideoThumbnailer))
29
 
 
30
 
    def testThumbnailerConstructorFilenameIsFolder(self):
31
 
        '''Tests proper handling of folders instead of files'''
32
 
        self.assertRaises(ThumbnailerException,
33
 
            VideoThumbnailer, os.path.abspath('.'))
34
 
 
35
 
    def testThumbnailerConstructorFilenameExists(self):
36
 
        '''Tests existence of file to thumbnail'''
37
 
        self.assertRaises(ThumbnailerException,
38
 
            VideoThumbnailer, os.path.abspath('foo-bar-baz'))
39
 
 
40
 
    def testThumbnailerConstructorSrc(self):
41
 
        '''Tests valid source types'''
42
 
        self.assertRaises(ThumbnailerException,
43
 
            VideoThumbnailer, os.path.abspath('.') +
44
 
            '/data/VideoThumbnailer/test.avi', src="foo")
45
 
 
46
 
    def testThumbnailAvi(self):
47
 
        '''Tests thumbnailing of Avi file'''
48
 
        thumbnailer = VideoThumbnailer(
49
 
            THIS_DIR + '/data/VideoThumbnailer/test.avi', src='video')
50
 
        if os.path.exists(thumbnailer._thumb_file):
51
 
            os.remove(thumbnailer._thumb_file)
52
 
        thumbnailer.create_thumbnail()
53
 
        if self.debug:
54
 
            print 'Expecting thumbnail : %s' % (self.thumbnailer._thumb_file)
55
 
        self.assertTrue(os.path.exists(thumbnailer._thumb_file))
56
 
 
57
 
    def testThumbnailFlv(self):
58
 
        '''Tests thumbnailing of a flash file'''
59
 
        thumbnailer = VideoThumbnailer(
60
 
            THIS_DIR + '/data/VideoThumbnailer/test.avi', src='video')
61
 
        if os.path.exists(thumbnailer._thumb_file):
62
 
            os.remove(thumbnailer._thumb_file)
63
 
        thumbnailer.create_thumbnail()
64
 
        if self.debug:
65
 
            print 'Expecting thumbnail : %s' % (self.thumbnailer._thumb_file)
66
 
        self.assertTrue(os.path.exists(thumbnailer._thumb_file))
67