genki-flickraw 0.8.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +161 -0
- data/examples/auth.rb +24 -0
- data/examples/interestingness.rb +6 -0
- data/examples/search.rb +22 -0
- data/examples/upload.rb +17 -0
- data/flickraw_rdoc.rb +131 -0
- data/lib/flickraw.rb +413 -0
- data/rakefile +14 -0
- data/test/test.rb +436 -0
- data/test/test_upload.rb +37 -0
- metadata +76 -0
data/rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
FlickRawOptions = {'lazyload' => true}
|
6
|
+
require './lib/flickraw'
|
7
|
+
require './flickraw_rdoc' if RUBY_VERSION >= "1.9"
|
8
|
+
|
9
|
+
Rake::RDocTask.new do |rd|
|
10
|
+
rd.main = "README.rdoc"
|
11
|
+
rd.rdoc_files.include "README.rdoc", "lib/flickraw.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
Rake::TestTask.new
|
data/test/test.rb
ADDED
@@ -0,0 +1,436 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib/', __FILE__)
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'flickraw'
|
8
|
+
|
9
|
+
# FlickRaw.shared_secret = # Shared secret
|
10
|
+
# flickr.auth.checkToken :auth_token => # Auth token
|
11
|
+
def flickr; $flickraw ||= FlickRaw::Flickr.new end
|
12
|
+
|
13
|
+
class Basic < Test::Unit::TestCase
|
14
|
+
def test_request
|
15
|
+
flickr_objects = %w{activity auth blogs collections commons contacts
|
16
|
+
favorites galleries groups interestingness machinetags panda
|
17
|
+
people photos photosets places prefs push reflection stats tags
|
18
|
+
test urls
|
19
|
+
}
|
20
|
+
assert_equal FlickRaw::Flickr.flickr_objects, flickr_objects
|
21
|
+
flickr_objects.each {|o|
|
22
|
+
assert_respond_to flickr, o
|
23
|
+
assert_kind_of FlickRaw::Request, eval("flickr." + o)
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_known
|
28
|
+
known_methods = %w{
|
29
|
+
flickr.activity.userComments
|
30
|
+
flickr.activity.userPhotos
|
31
|
+
flickr.auth.checkToken
|
32
|
+
flickr.auth.getFrob
|
33
|
+
flickr.auth.getFullToken
|
34
|
+
flickr.auth.getToken
|
35
|
+
flickr.auth.oauth.getAccessToken
|
36
|
+
flickr.blogs.getList
|
37
|
+
flickr.blogs.getServices
|
38
|
+
flickr.blogs.postPhoto
|
39
|
+
flickr.collections.getInfo
|
40
|
+
flickr.collections.getTree
|
41
|
+
flickr.commons.getInstitutions
|
42
|
+
flickr.contacts.getList
|
43
|
+
flickr.contacts.getListRecentlyUploaded
|
44
|
+
flickr.contacts.getPublicList
|
45
|
+
flickr.favorites.add
|
46
|
+
flickr.favorites.getContext
|
47
|
+
flickr.favorites.getList
|
48
|
+
flickr.favorites.getPublicList
|
49
|
+
flickr.favorites.remove
|
50
|
+
flickr.galleries.addPhoto
|
51
|
+
flickr.galleries.create
|
52
|
+
flickr.galleries.editMeta
|
53
|
+
flickr.galleries.editPhoto
|
54
|
+
flickr.galleries.editPhotos
|
55
|
+
flickr.galleries.getInfo
|
56
|
+
flickr.galleries.getList
|
57
|
+
flickr.galleries.getListForPhoto
|
58
|
+
flickr.galleries.getPhotos
|
59
|
+
flickr.groups.browse
|
60
|
+
flickr.groups.getInfo
|
61
|
+
flickr.groups.members.getList
|
62
|
+
flickr.groups.pools.add
|
63
|
+
flickr.groups.pools.getContext
|
64
|
+
flickr.groups.pools.getGroups
|
65
|
+
flickr.groups.pools.getPhotos
|
66
|
+
flickr.groups.pools.remove
|
67
|
+
flickr.groups.search
|
68
|
+
flickr.interestingness.getList
|
69
|
+
flickr.machinetags.getNamespaces
|
70
|
+
flickr.machinetags.getPairs
|
71
|
+
flickr.machinetags.getPredicates
|
72
|
+
flickr.machinetags.getRecentValues
|
73
|
+
flickr.machinetags.getValues
|
74
|
+
flickr.panda.getList
|
75
|
+
flickr.panda.getPhotos
|
76
|
+
flickr.people.findByEmail
|
77
|
+
flickr.people.findByUsername
|
78
|
+
flickr.people.getInfo
|
79
|
+
flickr.people.getPhotos
|
80
|
+
flickr.people.getPhotosOf
|
81
|
+
flickr.people.getPublicGroups
|
82
|
+
flickr.people.getPublicPhotos
|
83
|
+
flickr.people.getUploadStatus
|
84
|
+
flickr.photos.addTags
|
85
|
+
flickr.photos.comments.addComment
|
86
|
+
flickr.photos.comments.deleteComment
|
87
|
+
flickr.photos.comments.editComment
|
88
|
+
flickr.photos.comments.getList
|
89
|
+
flickr.photos.comments.getRecentForContacts
|
90
|
+
flickr.photos.delete
|
91
|
+
flickr.photos.geo.batchCorrectLocation
|
92
|
+
flickr.photos.geo.correctLocation
|
93
|
+
flickr.photos.geo.getLocation
|
94
|
+
flickr.photos.geo.getPerms
|
95
|
+
flickr.photos.geo.photosForLocation
|
96
|
+
flickr.photos.geo.removeLocation
|
97
|
+
flickr.photos.geo.setContext
|
98
|
+
flickr.photos.geo.setLocation
|
99
|
+
flickr.photos.geo.setPerms
|
100
|
+
flickr.photos.getAllContexts
|
101
|
+
flickr.photos.getContactsPhotos
|
102
|
+
flickr.photos.getContactsPublicPhotos
|
103
|
+
flickr.photos.getContext
|
104
|
+
flickr.photos.getCounts
|
105
|
+
flickr.photos.getExif
|
106
|
+
flickr.photos.getFavorites
|
107
|
+
flickr.photos.getInfo
|
108
|
+
flickr.photos.getNotInSet
|
109
|
+
flickr.photos.getPerms
|
110
|
+
flickr.photos.getRecent
|
111
|
+
flickr.photos.getSizes
|
112
|
+
flickr.photos.getUntagged
|
113
|
+
flickr.photos.getWithGeoData
|
114
|
+
flickr.photos.getWithoutGeoData
|
115
|
+
flickr.photos.licenses.getInfo
|
116
|
+
flickr.photos.licenses.setLicense
|
117
|
+
flickr.photos.notes.add
|
118
|
+
flickr.photos.notes.delete
|
119
|
+
flickr.photos.notes.edit
|
120
|
+
flickr.photos.people.add
|
121
|
+
flickr.photos.people.delete
|
122
|
+
flickr.photos.people.deleteCoords
|
123
|
+
flickr.photos.people.editCoords
|
124
|
+
flickr.photos.people.getList
|
125
|
+
flickr.photos.recentlyUpdated
|
126
|
+
flickr.photos.removeTag
|
127
|
+
flickr.photos.search
|
128
|
+
flickr.photos.setContentType
|
129
|
+
flickr.photos.setDates
|
130
|
+
flickr.photos.setMeta
|
131
|
+
flickr.photos.setPerms
|
132
|
+
flickr.photos.setSafetyLevel
|
133
|
+
flickr.photos.setTags
|
134
|
+
flickr.photos.transform.rotate
|
135
|
+
flickr.photos.upload.checkTickets
|
136
|
+
flickr.photosets.addPhoto
|
137
|
+
flickr.photosets.comments.addComment
|
138
|
+
flickr.photosets.comments.deleteComment
|
139
|
+
flickr.photosets.comments.editComment
|
140
|
+
flickr.photosets.comments.getList
|
141
|
+
flickr.photosets.create
|
142
|
+
flickr.photosets.delete
|
143
|
+
flickr.photosets.editMeta
|
144
|
+
flickr.photosets.editPhotos
|
145
|
+
flickr.photosets.getContext
|
146
|
+
flickr.photosets.getInfo
|
147
|
+
flickr.photosets.getList
|
148
|
+
flickr.photosets.getPhotos
|
149
|
+
flickr.photosets.orderSets
|
150
|
+
flickr.photosets.removePhoto
|
151
|
+
flickr.photosets.removePhotos
|
152
|
+
flickr.photosets.reorderPhotos
|
153
|
+
flickr.photosets.setPrimaryPhoto
|
154
|
+
flickr.places.find
|
155
|
+
flickr.places.findByLatLon
|
156
|
+
flickr.places.getChildrenWithPhotosPublic
|
157
|
+
flickr.places.getInfo
|
158
|
+
flickr.places.getInfoByUrl
|
159
|
+
flickr.places.getPlaceTypes
|
160
|
+
flickr.places.getShapeHistory
|
161
|
+
flickr.places.getTopPlacesList
|
162
|
+
flickr.places.placesForBoundingBox
|
163
|
+
flickr.places.placesForContacts
|
164
|
+
flickr.places.placesForTags
|
165
|
+
flickr.places.placesForUser
|
166
|
+
flickr.places.resolvePlaceId
|
167
|
+
flickr.places.resolvePlaceURL
|
168
|
+
flickr.places.tagsForPlace
|
169
|
+
flickr.prefs.getContentType
|
170
|
+
flickr.prefs.getGeoPerms
|
171
|
+
flickr.prefs.getHidden
|
172
|
+
flickr.prefs.getPrivacy
|
173
|
+
flickr.prefs.getSafetyLevel
|
174
|
+
flickr.push.getSubscriptions
|
175
|
+
flickr.push.getTopics
|
176
|
+
flickr.push.subscribe
|
177
|
+
flickr.push.unsubscribe
|
178
|
+
flickr.reflection.getMethodInfo
|
179
|
+
flickr.reflection.getMethods
|
180
|
+
flickr.stats.getCollectionDomains
|
181
|
+
flickr.stats.getCollectionReferrers
|
182
|
+
flickr.stats.getCollectionStats
|
183
|
+
flickr.stats.getCSVFiles
|
184
|
+
flickr.stats.getPhotoDomains
|
185
|
+
flickr.stats.getPhotoReferrers
|
186
|
+
flickr.stats.getPhotosetDomains
|
187
|
+
flickr.stats.getPhotosetReferrers
|
188
|
+
flickr.stats.getPhotosetStats
|
189
|
+
flickr.stats.getPhotoStats
|
190
|
+
flickr.stats.getPhotostreamDomains
|
191
|
+
flickr.stats.getPhotostreamReferrers
|
192
|
+
flickr.stats.getPhotostreamStats
|
193
|
+
flickr.stats.getPopularPhotos
|
194
|
+
flickr.stats.getTotalViews
|
195
|
+
flickr.tags.getClusterPhotos
|
196
|
+
flickr.tags.getClusters
|
197
|
+
flickr.tags.getHotList
|
198
|
+
flickr.tags.getListPhoto
|
199
|
+
flickr.tags.getListUser
|
200
|
+
flickr.tags.getListUserPopular
|
201
|
+
flickr.tags.getListUserRaw
|
202
|
+
flickr.tags.getRelated
|
203
|
+
flickr.test.echo
|
204
|
+
flickr.test.login
|
205
|
+
flickr.test.null
|
206
|
+
flickr.urls.getGroup
|
207
|
+
flickr.urls.getUserPhotos
|
208
|
+
flickr.urls.getUserProfile
|
209
|
+
flickr.urls.lookupGallery
|
210
|
+
flickr.urls.lookupGroup
|
211
|
+
flickr.urls.lookupUser
|
212
|
+
}
|
213
|
+
found_methods = flickr.reflection.getMethods
|
214
|
+
assert_instance_of FlickRaw::ResponseList, found_methods
|
215
|
+
assert_equal known_methods.sort, found_methods.to_a.sort
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_list
|
219
|
+
list = flickr.photos.getRecent :per_page => '10'
|
220
|
+
assert_instance_of FlickRaw::ResponseList, list
|
221
|
+
assert_equal(list.size, 10)
|
222
|
+
end
|
223
|
+
|
224
|
+
def people(user)
|
225
|
+
assert_equal "41650587@N02", user.id
|
226
|
+
assert_equal "41650587@N02", user.nsid
|
227
|
+
assert_equal "ruby_flickraw", user.username
|
228
|
+
end
|
229
|
+
|
230
|
+
def photo(info)
|
231
|
+
assert_equal "3839885270", info.id
|
232
|
+
assert_equal "41650587@N02", info.owner
|
233
|
+
assert_equal "6fb8b54e06", info.secret
|
234
|
+
assert_equal "2485", info.server
|
235
|
+
assert_equal 3, info.farm
|
236
|
+
assert_equal "cat", info.title
|
237
|
+
assert_equal 1, info.ispublic
|
238
|
+
end
|
239
|
+
|
240
|
+
# favorites
|
241
|
+
def test_favorites_getPublicList
|
242
|
+
list = flickr.favorites.getPublicList :user_id => "41650587@N02"
|
243
|
+
assert_equal 1, list.size
|
244
|
+
assert_equal "3829093290", list[0].id
|
245
|
+
end
|
246
|
+
|
247
|
+
# groups
|
248
|
+
def test_groups_getInfo
|
249
|
+
info = flickr.groups.getInfo :group_id => "51035612836@N01"
|
250
|
+
assert_equal "51035612836@N01", info.id
|
251
|
+
assert_equal "Flickr API", info.name
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_groups_search
|
255
|
+
list = flickr.groups.search :text => "Flickr API"
|
256
|
+
assert list.any? {|g| g.nsid == "51035612836@N01"}
|
257
|
+
end
|
258
|
+
|
259
|
+
# panda
|
260
|
+
def test_panda_getList
|
261
|
+
pandas = flickr.panda.getList
|
262
|
+
assert_equal ["ling ling", "hsing hsing", "wang wang"], pandas.to_a
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_panda_getList
|
266
|
+
pandas = flickr.panda.getPhotos :panda_name => "wang wang"
|
267
|
+
assert_equal "wang wang", pandas.panda
|
268
|
+
assert_respond_to pandas[0], :title
|
269
|
+
end
|
270
|
+
|
271
|
+
# people
|
272
|
+
def test_people_findByEmail
|
273
|
+
user = flickr.people.findByEmail :find_email => "flickraw@yahoo.com"
|
274
|
+
people user
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_people_findByUsername
|
278
|
+
user = flickr.people.findByUsername :username => "ruby_flickraw"
|
279
|
+
people user
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_people_getInfo
|
283
|
+
user = flickr.people.getInfo :user_id => "41650587@N02"
|
284
|
+
people user
|
285
|
+
assert_equal "Flickraw", user.realname
|
286
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/", user.photosurl
|
287
|
+
assert_equal "http://www.flickr.com/people/41650587@N02/", user.profileurl
|
288
|
+
assert_equal "http://m.flickr.com/photostream.gne?id=41630239", user.mobileurl
|
289
|
+
assert_equal 0, user.ispro
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_people_getPublicGroups
|
293
|
+
groups = flickr.people.getPublicGroups :user_id => "41650587@N02"
|
294
|
+
assert groups.to_a.empty?
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_people_getPublicPhotos
|
298
|
+
info = flickr.people.getPublicPhotos :user_id => "41650587@N02"
|
299
|
+
assert_equal 1, info.size
|
300
|
+
assert_equal "1", info.total
|
301
|
+
assert_equal 1, info.pages
|
302
|
+
assert_equal 1, info.page
|
303
|
+
photo info[0]
|
304
|
+
end
|
305
|
+
|
306
|
+
# photos
|
307
|
+
def test_photos_getInfo
|
308
|
+
id = "3839885270"
|
309
|
+
info = nil
|
310
|
+
assert_nothing_raised(FlickRaw::FailedResponse) {
|
311
|
+
info = flickr.photos.getInfo(:photo_id => id)
|
312
|
+
}
|
313
|
+
|
314
|
+
%w{id secret server farm license owner title description dates comments tags media}.each {|m|
|
315
|
+
assert_respond_to info, m
|
316
|
+
assert_not_nil info[m]
|
317
|
+
}
|
318
|
+
|
319
|
+
assert_equal id, info.id
|
320
|
+
assert_equal "cat", info.title
|
321
|
+
assert_equal "This is my cat", info.description
|
322
|
+
assert_equal "ruby_flickraw", info.owner["username"]
|
323
|
+
assert_equal "Flickraw", info.owner["realname"]
|
324
|
+
assert_equal %w{cat pet}, info.tags.map {|t| t.to_s}.sort
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_photos_getExif
|
328
|
+
info = flickr.photos.getExif :photo_id => "3839885270"
|
329
|
+
assert_equal "Canon DIGITAL IXUS 55", info.exif.find {|f| f.tag == "Model"}.raw
|
330
|
+
assert_equal "1/60", info.exif.find {|f| f.tag == "ExposureTime"}.raw
|
331
|
+
assert_equal "4.9", info.exif.find {|f| f.tag == "FNumber"}.raw
|
332
|
+
assert_equal "1600", info.exif.find {|f| f.tag == "RelatedImageWidth"}.raw
|
333
|
+
assert_equal "1200", info.exif.find {|f| f.tag == "RelatedImageHeight"}.raw
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_photos_getSizes
|
337
|
+
info = flickr.photos.getSizes :photo_id => "3839885270"
|
338
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/3839885270/sizes/l/", info.find {|f| f.label == "Large"}.url
|
339
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_b.jpg", info.find {|f| f.label == "Large"}.source
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_photos_search
|
343
|
+
info = flickr.photos.search :user_id => "41650587@N02"
|
344
|
+
photo info[0]
|
345
|
+
end
|
346
|
+
|
347
|
+
# photos.comments
|
348
|
+
def test_photos_comments_getList
|
349
|
+
comments = flickr.photos.comments.getList :photo_id => "3839885270"
|
350
|
+
assert_equal 1, comments.size
|
351
|
+
assert_equal "3839885270", comments.photo_id
|
352
|
+
assert_equal "41630239-3839885270-72157621986549875", comments[0].id
|
353
|
+
assert_equal "41650587@N02", comments[0].author
|
354
|
+
assert_equal "ruby_flickraw", comments[0].authorname
|
355
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/3839885270/#comment72157621986549875", comments[0].permalink
|
356
|
+
assert_equal "This is a cute cat !", comments[0].to_s
|
357
|
+
end
|
358
|
+
|
359
|
+
# tags
|
360
|
+
def test_tags_getListPhoto
|
361
|
+
tags = flickr.tags.getListPhoto :photo_id => "3839885270"
|
362
|
+
assert_equal 2, tags.tags.size
|
363
|
+
assert_equal "3839885270", tags.id
|
364
|
+
assert_equal %w{cat pet}, tags.tags.map {|t| t.to_s}.sort
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_tags_getListUser
|
368
|
+
tags = flickr.tags.getListUser :user_id => "41650587@N02"
|
369
|
+
assert_equal "41650587@N02", tags.id
|
370
|
+
assert_equal %w{cat pet}, tags.tags.sort
|
371
|
+
end
|
372
|
+
|
373
|
+
# urls
|
374
|
+
def test_urls_getGroup
|
375
|
+
info = flickr.urls.getGroup :group_id => "51035612836@N01"
|
376
|
+
assert_equal "51035612836@N01", info.nsid
|
377
|
+
assert_equal "http://www.flickr.com/groups/api/", info.url
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_urls_getUserPhotos
|
381
|
+
info = flickr.urls.getUserPhotos :user_id => "41650587@N02"
|
382
|
+
assert_equal "41650587@N02", info.nsid
|
383
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/", info.url
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_urls_getUserProfile
|
387
|
+
info = flickr.urls.getUserProfile :user_id => "41650587@N02"
|
388
|
+
assert_equal "41650587@N02", info.nsid
|
389
|
+
assert_equal "http://www.flickr.com/people/41650587@N02/", info.url
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_urls_lookupGroup
|
393
|
+
info = flickr.urls.lookupGroup :url => "http://www.flickr.com/groups/api/"
|
394
|
+
assert_equal "51035612836@N01", info.id
|
395
|
+
assert_equal "Flickr API", info.groupname
|
396
|
+
end
|
397
|
+
|
398
|
+
def test_urls_lookupUser
|
399
|
+
info = flickr.urls.lookupUser :url => "http://www.flickr.com/photos/41650587@N02/"
|
400
|
+
assert_equal "41650587@N02", info.id
|
401
|
+
assert_equal "ruby_flickraw", info.username
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_urls
|
405
|
+
id = "3839885270"
|
406
|
+
info = flickr.photos.getInfo(:photo_id => id)
|
407
|
+
|
408
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06.jpg", FlickRaw.url(info)
|
409
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_m.jpg", FlickRaw.url_m(info)
|
410
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_s.jpg", FlickRaw.url_s(info)
|
411
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_t.jpg", FlickRaw.url_t(info)
|
412
|
+
assert_equal "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_b.jpg", FlickRaw.url_b(info)
|
413
|
+
|
414
|
+
assert_equal "http://www.flickr.com/people/41650587@N02/", FlickRaw.url_profile(info)
|
415
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/", FlickRaw.url_photostream(info)
|
416
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/3839885270", FlickRaw.url_photopage(info)
|
417
|
+
assert_equal "http://www.flickr.com/photos/41650587@N02/sets/", FlickRaw.url_photosets(info)
|
418
|
+
assert_equal "http://flic.kr/p/6Rjq7s", FlickRaw.url_short(info)
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_url_escape
|
422
|
+
result_set = nil
|
423
|
+
assert_nothing_raised {
|
424
|
+
result_set = flickr.photos.search :text => "family vacation"
|
425
|
+
}
|
426
|
+
assert_operator result_set.total.to_i, :>=, 0
|
427
|
+
|
428
|
+
# Unicode tests
|
429
|
+
echo = nil
|
430
|
+
utf8_text = "Hélène François, €uro"
|
431
|
+
assert_nothing_raised {
|
432
|
+
echo = flickr.test.echo :utf8_text => utf8_text
|
433
|
+
}
|
434
|
+
assert_equal echo.utf8_text, utf8_text
|
435
|
+
end
|
436
|
+
end
|
data/test/test_upload.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib/', __FILE__)
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'flickraw'
|
8
|
+
|
9
|
+
# FlickRaw.api_key = # API key
|
10
|
+
# FlickRaw.shared_secret = # Shared secret
|
11
|
+
# flickr.access_token = # Auth token
|
12
|
+
# flickr.access_secret = # Auth token secret
|
13
|
+
def flickr; $flickraw ||= FlickRaw::Flickr.new end
|
14
|
+
|
15
|
+
class Upload < Test::Unit::TestCase
|
16
|
+
def test_upload
|
17
|
+
|
18
|
+
path = File.dirname(__FILE__) + '/image testée.jpg'
|
19
|
+
u = info = nil
|
20
|
+
title = "Titre de l'image testée"
|
21
|
+
description = "Ceci est la description de l'image testée"
|
22
|
+
assert_nothing_raised {
|
23
|
+
u = flickr.upload_photo path,
|
24
|
+
:title => title,
|
25
|
+
:description => description
|
26
|
+
}
|
27
|
+
|
28
|
+
assert_nothing_raised {
|
29
|
+
info = flickr.photos.getInfo :photo_id => u.to_s
|
30
|
+
}
|
31
|
+
|
32
|
+
assert_equal title, info.title
|
33
|
+
assert_equal description, info.description
|
34
|
+
|
35
|
+
assert_nothing_raised {flickr.photos.delete :photo_id => u.to_s}
|
36
|
+
end
|
37
|
+
end
|