Package elisa :: Package core :: Package tests :: Module test_thumbnailer
[hide private]
[frames] | no frames]

Source Code for Module elisa.core.tests.test_thumbnailer

 1  # Elisa - Home multimedia server 
 2  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 3  # All rights reserved. 
 4  # 
 5  # This file is available under one of two license agreements. 
 6  # 
 7  # This file is licensed under the GPL version 3. 
 8  # See "LICENSE.GPL" in the root of this distribution including a special 
 9  # exception to use Elisa with Fluendo's plugins. 
10  # 
11  # The GPL part of Elisa is also available under a commercial licensing 
12  # agreement from Fluendo. 
13  # See "LICENSE.Elisa" in the root directory of this distribution package 
14  # for details on that license. 
15   
16  from elisa.core.tests.elisa_test_case import ElisaTestCase, BoilerPlateApp 
17  from elisa.core import plugin 
18  from elisa.core import log, common 
19  from elisa.core import media_manager, metadata_manager, media_uri 
20  from twisted.internet import defer 
21  from elisa.plugins.base.local_media import LocalMedia 
22  from elisa.core.thumbnailer import Thumbnailer 
23   
24  import os 
25  import sys, platform 
26  import tempfile, shutil 
27   
28 -class FooPlugin(plugin.Plugin):
29 name = 'foo' 30 components = {'local_media': {'path': LocalMedia}}
31
32 -class TestThumbnailer(ElisaTestCase):
33
34 - def setUp(self):
35 ElisaTestCase.setUp(self) 36 37 from elisa.core.common import application 38 39 application.plugin_registry.register_plugin(FooPlugin) 40 41 m_manager = metadata_manager.MetadataManager() 42 application.media_manager = media_manager.MediaManager(m_manager) 43 44 c = application.plugin_registry.create_component 45 application.media_manager.register_component(c('foo:local_media')) 46 application.media_manager.start() 47 48 self._thumb_dir = tempfile.mkdtemp() 49 self._thumbnailer = Thumbnailer(self._thumb_dir)
50
51 - def tearDown(self):
52 from elisa.core.common import application 53 54 application.media_manager.stop() 55 shutil.rmtree(self._thumb_dir) 56 ElisaTestCase.tearDown(self)
57
58 - def test_thumbnail_image(self):
59 60 def got_picture(t): 61 self.failUnless(os.path.exists(t[0])) 62 got_picture.called = True
63 64 got_picture.called = False 65 66 uri = media_uri.MediaUri(u'file://./../elisa/core/tests/data/micro_cat.png') 67 dfr = self._thumbnailer.get_thumbnail(uri, 256, "image") 68 dfr.addCallback(got_picture) 69 dfr.addCallback(lambda r: self.check_called(got_picture)) 70 return dfr
71 72 if platform.system() == 'Windows': 73 test_thumbnail_image.skip = "Skipped under windows because get_media_type does not works" 74
75 - def test_thumbnail_video(self):
76 77 def got_video(t): 78 self.failUnless(os.path.exists(t[0])) 79 got_video.called = True
80 81 got_video.called = False 82 83 def video_error(msg): 84 print msg.getTraceback() 85 86 uri = media_uri.MediaUri(u'file://./../elisa/core/tests/data/test.ogm') 87 dfr = self._thumbnailer.get_thumbnail(uri, 256, "video") 88 dfr.addCallback(got_video) 89 dfr.addErrback(video_error) 90 dfr.addCallback(lambda r: self.check_called(got_video)) 91 return dfr 92 test_thumbnail_video.skip = 'Video thumbnails are (temporarily?) disabled' 93 94 if platform.system() == 'Windows': 95 test_thumbnail_video.skip = "Skipped under windows due to glib2 reactor issues with unit test" 96