1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from elisa.core.tests.test_media_provider import TestMediaProvider
17 from elisa.core import db_backend
18 from elisa.core.media_uri import MediaUri
19 import os, platform
20 from twisted.internet import defer
21 import tempfile
22
23
24
58
81
82 def got_next3(next):
83 self.assertEquals(next, MediaUri(u'fspot:///home/kaleo/Desktop/media/pictures/NATURE-ChristmasOnMaui_1280x1024.jpg?tag_id=1#6'))
84
85 dfr = self.component.next_location(next, root=start)
86 dfr.addCallback(got_next4)
87 return dfr
88
89 def got_next4(next):
90 self.assertEquals(next, MediaUri(u'fspot:///home/kaleo/Desktop/media/pictures/Julia.png?tag_id=3#5'))
91 dfr = self.component.next_location(next, root=start)
92 dfr.addCallback(got_next5)
93 return dfr
94
95 def got_next5(next):
96 self.assertEquals(next, MediaUri(u'fspot:///home/kaleo/Desktop/media/pictures/369113572_24fc34005a_o_d.jpg?tag_id=3#2'))
97 dfr = self.component.next_location(next, root=start)
98 dfr.addCallback(got_next6)
99 return dfr
100
101 def got_next6(next):
102 self.assertEquals(next, MediaUri(u'fspot:///home/kaleo/Desktop/media/pictures/308567765_b904571e9f_o.jpg?tag_id=4#1'))
103 dfr = self.component.next_location(next, root=start)
104 dfr.addCallback(got_next7)
105 return dfr
106
107 def got_next7(next):
108 self.assertEquals(next, MediaUri(u'fspot:///home/kaleo/Desktop/media/pictures/NATURE-KosametThailand_1280x1024.jpg?tag_id=4#7'))
109 dfr = self.component.next_location(next, root=start)
110 dfr.addCallback(got_next8)
111 return dfr
112
113 def got_next8(next):
114
115 self.failIf(next is None)
116
117 dfr = self.component.next_location(start, root=start)
118 dfr.addCallback(got_next1)
119 return dfr
120
121
143
144 def got_next3(next):
145 self.assertEquals(next, MediaUri(u'fspot:///home/phil/Photos/2002/4/1/lambs.jpg?tag_id=7#22'))
146 got_next3.called = True
147 return next
148
149 got_next3.called = False
150
151 def check_called(uri):
152 self.check_called(got_next3)
153 return uri
154
155 dfr = self.component.next_location(start, root=start)
156 dfr.addCallback(got_next1)
157 dfr.addCallback(check_called)
158 return dfr
159
163
174
175 def got_next2(next):
176 self.assertEquals(next, MediaUri(u'fspot:///Favorites?id=1&tag_id=-1'))
177
178 dfr = self.component.next_location(next, root=start)
179 dfr.addCallback(got_next3)
180 return dfr
181
182
183 def got_next3(next):
184 self.assertEquals(next, MediaUri(u'fspot:///Hidden?id=2&tag_id=-1'))
185
186 dfr = self.component.next_location(next, root=start)
187 dfr.addCallback(got_next4)
188 return dfr
189
190 def got_next4(next):
191 self.assertEquals(next, MediaUri(u'fspot:///People?id=3&tag_id=-1'))
192
193 dfr = self.component.next_location(next, root=start)
194 dfr.addCallback(got_next5)
195 return dfr
196
197 def got_next5(next):
198 self.assertEquals(next, MediaUri(u'fspot:///tmp?id=6&tag_id=3'))
199
200 dfr = self._from_tmp_tag()
201 dfr.addCallback(lambda uri: self.component.next_location(uri,
202 root=start))
203 dfr.addCallback(got_next6)
204 return dfr
205
206 def got_next6(next):
207 self.assertEquals(next, MediaUri(u'fspot:///home/phil/Photos/2004/7/30/rabbit.jpg?tag_id=6#25'))
208
209 dfr = self.component.next_location(next, root=start)
210 dfr.addCallback(got_next7)
211
212 return dfr
213
214 def got_next7(next):
215 self.assertEquals(next, MediaUri(u'fspot:///home/phil/Photos/2004/7/30/rabbit.jpg?tag_id=6#10'))
216
217 dfr = self.component.next_location(next, root=start)
218 dfr.addCallback(got_next8)
219 return dfr
220
221 def got_next8(next):
222 self.assertEquals(next, MediaUri(u'fspot:///home/phil/Photos/2006/8/22/leopard.jpg?tag_id=6#23'))
223
224 dfr = self.component.next_location(next, root=start)
225 dfr.addCallback(got_next9)
226 return dfr
227
228 def got_next9(next):
229 self.assertEquals(next, MediaUri(u'fspot:///home/phil/Photos/2003/1/29/hippo.jpg?tag_id=3#20'))
230 got_next9.called = True
231
232 got_next9.called = False
233
234 dfr = self.component.next_location(start, root=start)
235 dfr.addCallback(got_next1)
236 dfr.addCallback(lambda r: self.check_called(got_next9))
237 return dfr
238
244
245 u1 = MediaUri(u'fspot:///home/phil/Photos/2003/1/29/hippo.jpg?tag_id=3#20')
246 d1 = self.component.get_media_type(u1)
247 d1.addCallback(check_file)
248
249 def check_dir(result):
250 self.assertEquals(result['file_type'], 'directory')
251 self.assertEquals(result['mime_type'], '')
252
253 u2 = MediaUri(u'fspot:///tmp?id=6&tag_id=3')
254 d2 = self.component.get_media_type(u2)
255 d2.addCallback(check_dir)
256
257 d = defer.DeferredList([d1,d2])
258 return d
259
264
265 u1 = MediaUri(u'fspot:///home/phil/Photos/2003/1/29/hippo.jpg?tag_id=3#20')
266 d1 = self.component.has_children_with_types(u1,['image',])
267 d1.addCallback(check_file)
268
269 def check_dir(result):
270 self.assertEquals(result, True)
271
272 u2 = MediaUri(u'fspot:///tmp?id=6&tag_id=3')
273 d2 = self.component.has_children_with_types(u2, ['image',])
274 d2.addCallback(check_dir)
275
276 def check_dir2(result):
277 self.assertEquals(result, True)
278
279 u3 = MediaUri(u'fspot:///')
280 d3 = self.component.has_children_with_types(u3, ['directory',])
281 d3.addCallback(check_dir2)
282
283 u4 = MediaUri("fspot:///subtmp?id=7&tag_id=6")
284 d4 = self.component.has_children_with_types(u4, ['directory', 'image'])
285 d4.addCallback(check_dir2)
286
287 d = defer.DeferredList([d1,d2,d3,d4])
288 return d
289
300
301 d1 = self.component.get_direct_children(MediaUri('fspot:///'),
302 [])
303 d1.addCallback(got_children)
304 return d1
305
314
315 d1 = self.component.get_direct_children(MediaUri("fspot:///subtmp?id=7&tag_id=6"),
316 [])
317 d1.addCallback(got_children)
318 return d1
319
323