1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
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
94