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

Source Code for Module elisa.core.tests.test_mime_getter

 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 
17  from elisa.core.utils.mime_getter import MimeGetter 
18  from twisted.internet import defer, threads 
19   
20 -class TestMimeGetter(ElisaTestCase):
21 22 skip = "disabled until actually used and working well in Elisa" 23
25 26 mime = MimeGetter() 27 28 def callIn(result, dict): 29 self.assertEquals(result,dict)
30 31 def start_test(): 32 df = mime.get_type('filesrc', 33 '../sample_data/music/01_open_source__magic_mushrooms.ogg') 34 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 35 df = mime.get_type('filesrc', 36 '../sample_data/music/02_icarus_grounded__jeffrey_altergott.ogg') 37 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 38 39 df = mime.get_type('filesrc', 40 '../sample_data/music/03_monkey_bones__trailer_park_everlys.ogg') 41 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 42 43 df = mime.get_type('filesrc', 44 '../sample_data/movies/gstreamer.ogm') 45 df.addCallback(callIn, {'file_type': 'video', 'mime_type': 'application/ogg'}) 46 47 df = mime.get_type('filesrc', 48 '../sample_data/movies/') 49 df.addCallback(callIn, {'file_type': '', 'mime_type' : None}) 50 df = mime.get_type('filesrc', 51 '../sample_data/pictures/animals/rabbit.jpg') 52 df.addCallback(callIn, {'file_type': 'image', 'mime_type':'image/jpeg'} )
53 54 55 56 return threads.deferToThread(start_test) 57 58
59 - def test_get_mimetypes_gnomevfssrc(self):
60 61 mime = MimeGetter('gnomevfssrc') 62 63 def callIn(result, dict): 64 self.assertEquals(result,dict)
65 66 def start_test(): 67 df = mime.get_type('gnomevfssrc', 68 '../sample_data/music/01_open_source__magic_mushrooms.ogg') 69 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 70 df = mime.get_type('gnomevfssrc', 71 '../sample_data/music/02_icarus_grounded__jeffrey_altergott.ogg') 72 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 73 74 df = mime.get_type('gnomevfssrc', 75 '../sample_data/music/03_monkey_bones__trailer_park_everlys.ogg') 76 df.addCallback(callIn, {'file_type': 'audio', 'mime_type': 'application/ogg'}) 77 78 df = mime.get_type('gnomevfssrc', 79 '../sample_data/movies/gstreamer.ogm') 80 df.addCallback(callIn, {'file_type': 'video', 'mime_type': 'application/ogg'}) 81 82 df = mime.get_type('gnomevfssrc', 83 '../sample_data/movies/') 84 df.addCallback(callIn, {'file_type': '', 'mime_type' : None}) 85 df = mime.get_type('gnomevfssrc', 86 '../sample_data/pictures/animals/rabbit.jpg') 87 df.addCallback(callIn, {'file_type': 'image', 'mime_type':'image/jpeg'} ) 88 89 90 91 return threads.deferToThread(start_test) 92 93 #test_get_mimetypes_gnomevfssrc.skip = "doesn't seem to work if gnomevfssrc 94