flickr 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc DELETED
@@ -1,185 +0,0 @@
1
- = Flickr
2
-
3
- Flickr is a library to access the Flickr[https://flickr.com] API in a simple way.
4
- It maps exactly the methods described in {the official API documentation}[https://www.flickr.com/services/api/].
5
- It also tries to present the data returned in a simple and intuitive way.
6
- The methods are fetched from Flickr when loading the library by using introspection capabilities. So it is always up-to-date with regards to new methods added by Flickr.
7
-
8
- The github repository: https://github.com/hanklords/flickraw
9
-
10
- = Installation
11
- Type this in a console (you might need to be superuser)
12
-
13
- gem install flickr
14
-
15
- This will recreate the documentation by fetching the method descriptions from Flickr and then virtually plugging them in standard rdoc documentation.
16
- $ cd flickr
17
- $ rake rdoc
18
-
19
- = Features
20
-
21
- * Minimal dependencies
22
- * Complete support of Flickr API. This doesn't require an update of the library
23
- * Ruby syntax similar to the Flickr API
24
- * Flickr authentication
25
- * HTTPS Support
26
- * Photo upload
27
- * Proxy support
28
- * Flickr URLs helpers
29
-
30
- = Usage
31
-
32
- == Getting started
33
-
34
- To use the Flickr API, you must first obtain an API key and shared secret from Flickr. You can do this by logging in to Flickr and creating an application here[https://www.flickr.com/services/apps/create/apply]. API keys are usually granted automatically and instantly.
35
-
36
- require 'flickr'
37
-
38
- # The credentials can be provided as parameters:
39
-
40
- flickr = Flickr.new "YOUR API KEY", "YOUR SHARED SECRET"
41
-
42
- # Alternatively, if the API key and Shared Secret are not provided, Flickr will attempt to read them
43
- # from environment variables:
44
- # ENV['FLICKR_API_KEY']
45
- # ENV['FLICKR_SHARED_SECRET']
46
-
47
- flickr = Flickr.new
48
-
49
- # Flickr will raise an error if either parameter is not explicitly provided, or available via environment variables.
50
-
51
-
52
- == Simple
53
-
54
- list = flickr.photos.getRecent
55
-
56
- id = list[0].id
57
- secret = list[0].secret
58
- info = flickr.photos.getInfo :photo_id => id, :secret => secret
59
-
60
- puts info.title # => "PICT986"
61
- puts info.dates.taken # => "2006-07-06 15:16:18"
62
-
63
-
64
- sizes = flickr.photos.getSizes :photo_id => id
65
-
66
- original = sizes.find { |s| s.label == 'Original' }
67
- puts original.width # => "800" -- may fail if they have no original marked image
68
-
69
- == Authentication
70
-
71
- token = flickr.get_request_token
72
- auth_url = flickr.get_authorize_url(token['oauth_token'], :perms => 'delete')
73
-
74
- puts "Open this url in your browser to complete the authentication process: #{auth_url}"
75
- puts "Copy here the number given when you complete the process."
76
- verify = gets.strip
77
-
78
- begin
79
- flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
80
- login = flickr.test.login
81
- puts "You are now authenticated as #{login.username} with token #{flickr.access_token} and secret #{flickr.access_secret}"
82
- rescue Flickr::FailedResponse => e
83
- puts "Authentication failed : #{e.msg}"
84
- end
85
-
86
- If the user has already been authenticated, you can reuse the access token and access secret:
87
-
88
- flickr.access_token = "... Your access token ..."
89
- flickr.access_secret = "... Your access secret ..."
90
-
91
- # From here you are logged:
92
- login = flickr.test.login
93
- puts "You are now authenticated as #{login.username}"
94
-
95
- If you need to have several users authenticated at the same time in your application (ex: a public web application) you need to create separate Flickr objects since it keeps the authentication data internally.
96
-
97
- flickr = Flickr.new
98
-
99
- == Upload
100
-
101
- PHOTO_PATH = 'photo.jpg'
102
-
103
- # You need to be authenticated to do that, see the previous examples.
104
- flickr.upload_photo PHOTO_PATH, :title => "Title", :description => "This is the description"
105
-
106
- == Caching
107
-
108
- The first time the Flickr object is instantiated, it will download the current Flickr API definition and dynamically create all the required classes and objects. This is how the gem remains up-to-date without requiring updates.
109
-
110
- Unfortunately this adds a significant delay to startup, but the Flickr gem can be configured to cache the API definition to a local file. Just set a file location before the Flickr class is instantiated:
111
-
112
- Flickr.cache = '/tmp/flickr-api.yml'
113
- flickr = Flickr.new
114
-
115
- == Proxy
116
-
117
- require 'flickr'
118
- Flickr.proxy = "https://user:pass@proxy.example.com:3129/"
119
-
120
- === Server Certificate Verification
121
-
122
- Server certificate verification is enabled by default. If you don't want to check the server certificate:
123
-
124
- require 'flickr'
125
- Flickr.check_certificate = false
126
-
127
- === CA Certificate File Path
128
-
129
- OpenSSL::X509::DEFAULT_CERT_FILE is used as a CA certificate file. If you want to change the path:
130
-
131
- require 'flickr'
132
- Flickr.ca_file = '/path/to/cacert.pem'
133
-
134
- You can also specify a path to a directory with a number of certifications:
135
-
136
- Flickr.ca_path = '/path/to/certificates'
137
-
138
- == Flickr URL Helpers
139
-
140
- There are some helpers to build Flickr urls:
141
-
142
- === url, url_m, url_s, url_t, url_b, url_z, url_q, url_n, url_c, url_o
143
-
144
- # url_s : Square
145
- # url_q : Large Square
146
- # url_t : Thumbnail
147
- # url_m : Small
148
- # url_n : Small 320
149
- # url : Medium
150
- # url_z : Medium 640
151
- # url_c : Medium 800
152
- # url_b : Large
153
- # url_o : Original
154
-
155
- info = flickr.photos.getInfo(:photo_id => "3839885270")
156
- Flickr.url_b(info) # => "https://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_b.jpg"
157
-
158
- === url_profile
159
-
160
- info = flickr.photos.getInfo(:photo_id => "3839885270")
161
- Flickr.url_profile(info) # => "https://www.flickr.com/people/41650587@N02/"
162
-
163
- === url_photopage
164
-
165
- info = flickr.photos.getInfo(:photo_id => "3839885270")
166
- Flickr.url_photopage(info) # => "https://www.flickr.com/photos/41650587@N02/3839885270"
167
-
168
- === url_photoset, url_photosets
169
-
170
- info = flickr.photos.getInfo(:photo_id => "3839885270")
171
- Flickr.url_photosets(info) # => "https://www.flickr.com/photos/41650587@N02/sets/"
172
-
173
- === url_short, url_short_m, url_short_s, url_short_t
174
-
175
- info = flickr.photos.getInfo(:photo_id => "3839885270")
176
- Flickr.url_short(info) # => "https://flic.kr/p/6Rjq7s"
177
-
178
- === url_photostream
179
-
180
- info = flickr.photos.getInfo(:photo_id => "3839885270")
181
- Flickr.url_photostream(info) # => "https://www.flickr.com/photos/41650587@N02/"
182
-
183
- == Examples
184
-
185
- See the _examples_ directory to find more examples.
data/test/test.rb DELETED
@@ -1,471 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- lib = File.dirname(__FILE__)
4
- $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'flickr'
7
- require 'test/unit'
8
-
9
- class Basic < Test::Unit::TestCase
10
-
11
- def setup
12
- @flickr = ::Flickr.new
13
- end
14
-
15
- def test_request
16
- flickr_objects = %w{
17
- activity auth blogs cameras collections commons contacts
18
- favorites galleries groups interestingness machinetags panda
19
- people photos photosets places prefs profile push reflection
20
- stats tags test testimonials urls
21
- }
22
-
23
- flickr_objects.each { |o|
24
- assert_respond_to @flickr, o.to_sym, "Flickr instance should respond to #{o}"
25
- assert_kind_of Flickr::Request, @flickr.send(o.to_sym)
26
- }
27
- end
28
-
29
- def test_known
30
- known_methods = %w{
31
- flickr.activity.userComments
32
- flickr.activity.userPhotos
33
- flickr.auth.checkToken
34
- flickr.auth.getFrob
35
- flickr.auth.getFullToken
36
- flickr.auth.getToken
37
- flickr.auth.oauth.checkToken
38
- flickr.auth.oauth.getAccessToken
39
- flickr.blogs.getList
40
- flickr.blogs.getServices
41
- flickr.blogs.postPhoto
42
- flickr.cameras.getBrandModels
43
- flickr.cameras.getBrands
44
- flickr.collections.getInfo
45
- flickr.collections.getTree
46
- flickr.commons.getInstitutions
47
- flickr.contacts.getList
48
- flickr.contacts.getListRecentlyUploaded
49
- flickr.contacts.getPublicList
50
- flickr.contacts.getTaggingSuggestions
51
- flickr.favorites.add
52
- flickr.favorites.getContext
53
- flickr.favorites.getList
54
- flickr.favorites.getPublicList
55
- flickr.favorites.remove
56
- flickr.galleries.addPhoto
57
- flickr.galleries.create
58
- flickr.galleries.editMeta
59
- flickr.galleries.editPhoto
60
- flickr.galleries.editPhotos
61
- flickr.galleries.getInfo
62
- flickr.galleries.getList
63
- flickr.galleries.getListForPhoto
64
- flickr.galleries.getPhotos
65
- flickr.galleries.removePhoto
66
- flickr.groups.browse
67
- flickr.groups.discuss.replies.add
68
- flickr.groups.discuss.replies.delete
69
- flickr.groups.discuss.replies.edit
70
- flickr.groups.discuss.replies.getInfo
71
- flickr.groups.discuss.replies.getList
72
- flickr.groups.discuss.topics.add
73
- flickr.groups.discuss.topics.getInfo
74
- flickr.groups.discuss.topics.getList
75
- flickr.groups.getInfo
76
- flickr.groups.join
77
- flickr.groups.joinRequest
78
- flickr.groups.leave
79
- flickr.groups.members.getList
80
- flickr.groups.pools.add
81
- flickr.groups.pools.getContext
82
- flickr.groups.pools.getGroups
83
- flickr.groups.pools.getPhotos
84
- flickr.groups.pools.remove
85
- flickr.groups.search
86
- flickr.interestingness.getList
87
- flickr.machinetags.getNamespaces
88
- flickr.machinetags.getPairs
89
- flickr.machinetags.getPredicates
90
- flickr.machinetags.getRecentValues
91
- flickr.machinetags.getValues
92
- flickr.panda.getList
93
- flickr.panda.getPhotos
94
- flickr.people.findByEmail
95
- flickr.people.findByUsername
96
- flickr.people.getGroups
97
- flickr.people.getInfo
98
- flickr.people.getLimits
99
- flickr.people.getPhotos
100
- flickr.people.getPhotosOf
101
- flickr.people.getPublicGroups
102
- flickr.people.getPublicPhotos
103
- flickr.people.getUploadStatus
104
- flickr.photos.addTags
105
- flickr.photos.comments.addComment
106
- flickr.photos.comments.deleteComment
107
- flickr.photos.comments.editComment
108
- flickr.photos.comments.getList
109
- flickr.photos.comments.getRecentForContacts
110
- flickr.photos.delete
111
- flickr.photos.geo.batchCorrectLocation
112
- flickr.photos.geo.correctLocation
113
- flickr.photos.geo.getLocation
114
- flickr.photos.geo.getPerms
115
- flickr.photos.geo.photosForLocation
116
- flickr.photos.geo.removeLocation
117
- flickr.photos.geo.setContext
118
- flickr.photos.geo.setLocation
119
- flickr.photos.geo.setPerms
120
- flickr.photos.getAllContexts
121
- flickr.photos.getContactsPhotos
122
- flickr.photos.getContactsPublicPhotos
123
- flickr.photos.getContext
124
- flickr.photos.getCounts
125
- flickr.photos.getExif
126
- flickr.photos.getFavorites
127
- flickr.photos.getInfo
128
- flickr.photos.getNotInSet
129
- flickr.photos.getPerms
130
- flickr.photos.getPopular
131
- flickr.photos.getRecent
132
- flickr.photos.getSizes
133
- flickr.photos.getUntagged
134
- flickr.photos.getWithGeoData
135
- flickr.photos.getWithoutGeoData
136
- flickr.photos.licenses.getInfo
137
- flickr.photos.licenses.setLicense
138
- flickr.photos.notes.add
139
- flickr.photos.notes.delete
140
- flickr.photos.notes.edit
141
- flickr.photos.people.add
142
- flickr.photos.people.delete
143
- flickr.photos.people.deleteCoords
144
- flickr.photos.people.editCoords
145
- flickr.photos.people.getList
146
- flickr.photos.recentlyUpdated
147
- flickr.photos.removeTag
148
- flickr.photos.search
149
- flickr.photos.setContentType
150
- flickr.photos.setDates
151
- flickr.photos.setMeta
152
- flickr.photos.setPerms
153
- flickr.photos.setSafetyLevel
154
- flickr.photos.setTags
155
- flickr.photos.suggestions.approveSuggestion
156
- flickr.photos.suggestions.getList
157
- flickr.photos.suggestions.rejectSuggestion
158
- flickr.photos.suggestions.removeSuggestion
159
- flickr.photos.suggestions.suggestLocation
160
- flickr.photos.transform.rotate
161
- flickr.photos.upload.checkTickets
162
- flickr.photosets.addPhoto
163
- flickr.photosets.comments.addComment
164
- flickr.photosets.comments.deleteComment
165
- flickr.photosets.comments.editComment
166
- flickr.photosets.comments.getList
167
- flickr.photosets.create
168
- flickr.photosets.delete
169
- flickr.photosets.editMeta
170
- flickr.photosets.editPhotos
171
- flickr.photosets.getContext
172
- flickr.photosets.getInfo
173
- flickr.photosets.getList
174
- flickr.photosets.getPhotos
175
- flickr.photosets.orderSets
176
- flickr.photosets.removePhoto
177
- flickr.photosets.removePhotos
178
- flickr.photosets.reorderPhotos
179
- flickr.photosets.setPrimaryPhoto
180
- flickr.places.find
181
- flickr.places.findByLatLon
182
- flickr.places.getChildrenWithPhotosPublic
183
- flickr.places.getInfo
184
- flickr.places.getInfoByUrl
185
- flickr.places.getPlaceTypes
186
- flickr.places.getShapeHistory
187
- flickr.places.getTopPlacesList
188
- flickr.places.placesForBoundingBox
189
- flickr.places.placesForContacts
190
- flickr.places.placesForTags
191
- flickr.places.placesForUser
192
- flickr.places.resolvePlaceId
193
- flickr.places.resolvePlaceURL
194
- flickr.places.tagsForPlace
195
- flickr.prefs.getContentType
196
- flickr.prefs.getGeoPerms
197
- flickr.prefs.getHidden
198
- flickr.prefs.getPrivacy
199
- flickr.prefs.getSafetyLevel
200
- flickr.profile.getProfile
201
- flickr.push.getSubscriptions
202
- flickr.push.getTopics
203
- flickr.push.subscribe
204
- flickr.push.unsubscribe
205
- flickr.reflection.getMethodInfo
206
- flickr.reflection.getMethods
207
- flickr.stats.getCSVFiles
208
- flickr.stats.getCollectionDomains
209
- flickr.stats.getCollectionReferrers
210
- flickr.stats.getCollectionStats
211
- flickr.stats.getPhotoDomains
212
- flickr.stats.getPhotoReferrers
213
- flickr.stats.getPhotoStats
214
- flickr.stats.getPhotosetDomains
215
- flickr.stats.getPhotosetReferrers
216
- flickr.stats.getPhotosetStats
217
- flickr.stats.getPhotostreamDomains
218
- flickr.stats.getPhotostreamReferrers
219
- flickr.stats.getPhotostreamStats
220
- flickr.stats.getPopularPhotos
221
- flickr.stats.getTotalViews
222
- flickr.tags.getClusterPhotos
223
- flickr.tags.getClusters
224
- flickr.tags.getHotList
225
- flickr.tags.getListPhoto
226
- flickr.tags.getListUser
227
- flickr.tags.getListUserPopular
228
- flickr.tags.getListUserRaw
229
- flickr.tags.getMostFrequentlyUsed
230
- flickr.tags.getRelated
231
- flickr.test.echo
232
- flickr.test.login
233
- flickr.test.null
234
- flickr.testimonials.addTestimonial
235
- flickr.testimonials.approveTestimonial
236
- flickr.testimonials.deleteTestimonial
237
- flickr.testimonials.editTestimonial
238
- flickr.testimonials.getAllTestimonialsAbout
239
- flickr.testimonials.getAllTestimonialsAboutBy
240
- flickr.testimonials.getAllTestimonialsBy
241
- flickr.testimonials.getPendingTestimonialsAbout
242
- flickr.testimonials.getPendingTestimonialsAboutBy
243
- flickr.testimonials.getPendingTestimonialsBy
244
- flickr.testimonials.getTestimonialsAbout
245
- flickr.testimonials.getTestimonialsAboutBy
246
- flickr.testimonials.getTestimonialsBy
247
- flickr.urls.getGroup
248
- flickr.urls.getUserPhotos
249
- flickr.urls.getUserProfile
250
- flickr.urls.lookupGallery
251
- flickr.urls.lookupGroup
252
- flickr.urls.lookupUser
253
- }
254
- found_methods = @flickr.reflection.getMethods
255
- assert_instance_of Flickr::ResponseList, found_methods
256
- assert_equal known_methods.sort, found_methods.to_a.sort
257
- end
258
-
259
- def test_list
260
- list = @flickr.photos.getRecent :per_page => '10'
261
- assert_instance_of Flickr::ResponseList, list
262
- assert_equal(list.size, 10)
263
- end
264
-
265
- def people(user)
266
- assert_equal "41650587@N02", user.id
267
- assert_equal "41650587@N02", user.nsid
268
- assert_equal "ruby_flickraw", user.username
269
- end
270
-
271
- def photo(info)
272
- assert_equal "3839885270", info.id
273
- assert_equal "41650587@N02", info.owner
274
- assert_equal "6fb8b54e06", info.secret
275
- assert_equal "2485", info.server
276
- assert_equal 3, info.farm
277
- assert_equal "cat", info.title
278
- assert_equal 1, info.ispublic
279
- end
280
-
281
- # favorites
282
- def test_favorites_getPublicList
283
- list = @flickr.favorites.getPublicList :user_id => "41650587@N02"
284
- assert_equal 1, list.size
285
- assert_equal "3829093290", list[0].id
286
- end
287
-
288
- # groups
289
- def test_groups_getInfo
290
- info = @flickr.groups.getInfo :group_id => "51035612836@N01"
291
- assert_equal "51035612836@N01", info.id
292
- assert_equal "Flickr API", info.name
293
- end
294
-
295
- def test_groups_search
296
- list = @flickr.groups.search :text => "Flickr API"
297
- assert list.any? { |g| g.nsid == "51035612836@N01"}
298
- end
299
-
300
- # people
301
- def test_people_findByEmail
302
- user = @flickr.people.findByEmail :find_email => "flickraw@yahoo.com"
303
- people user
304
- end
305
-
306
- def test_people_findByUsername
307
- user = @flickr.people.findByUsername :username => "ruby_flickraw"
308
- people user
309
- end
310
-
311
- def test_people_getInfo
312
- user = @flickr.people.getInfo :user_id => "41650587@N02"
313
- people user
314
- assert_equal "Flickraw", user.realname
315
- assert_equal "https://www.flickr.com/photos/41650587@N02/", user.photosurl
316
- assert_equal "https://www.flickr.com/people/41650587@N02/", user.profileurl
317
- assert_equal "https://m.flickr.com/photostream.gne?id=41630239", user.mobileurl
318
- assert_equal 0, user.ispro
319
- end
320
-
321
- def test_people_getPublicGroups
322
- groups = @flickr.people.getPublicGroups :user_id => "41650587@N02"
323
- assert groups.to_a.empty?
324
- end
325
-
326
- def test_people_getPublicPhotos
327
- info = @flickr.people.getPublicPhotos :user_id => "41650587@N02"
328
- assert_equal 1, info.size
329
- assert_equal "1", info.total
330
- assert_equal 1, info.pages
331
- assert_equal 1, info.page
332
- photo info[0]
333
- end
334
-
335
- # photos
336
- def test_photos_getInfo
337
- id = "3839885270"
338
- info = nil
339
- assert_nothing_raised(Flickr::FailedResponse) {
340
- info = @flickr.photos.getInfo(:photo_id => id)
341
- }
342
-
343
- %w{id secret server farm license owner title description dates comments tags media}.each { |m|
344
- assert_respond_to info, m
345
- assert_not_nil info[m]
346
- }
347
-
348
- assert_equal id, info.id
349
- assert_equal "cat", info.title
350
- assert_equal "This is my cat", info.description
351
- assert_equal "ruby_flickraw", info.owner["username"]
352
- assert_equal "Flickraw", info.owner["realname"]
353
- assert_equal %w{cat pet}, info.tags.map { |t| t.to_s}.sort
354
- end
355
-
356
- def test_photos_getExif
357
- info = @flickr.photos.getExif :photo_id => "3839885270"
358
- assert_equal "Canon DIGITAL IXUS 55", info.exif.find { |f| f.tag == "Model"}.raw
359
- assert_equal "1/60", info.exif.find { |f| f.tag == "ExposureTime"}.raw
360
- assert_equal "4.9", info.exif.find { |f| f.tag == "FNumber"}.raw
361
- assert_equal "1600", info.exif.find { |f| f.tag == "RelatedImageWidth"}.raw
362
- assert_equal "1200", info.exif.find { |f| f.tag == "RelatedImageHeight"}.raw
363
- end
364
-
365
- def test_photos_getSizes
366
- info = @flickr.photos.getSizes :photo_id => "3839885270"
367
- assert_equal "https://www.flickr.com/photos/41650587@N02/3839885270/sizes/l/", info.find { |f| f.label == "Large" }.url
368
- source = "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_b.jpg"
369
-
370
- assert_equal source, info.find { |f| f.label == "Large"}.source
371
- end
372
-
373
- def test_photos_search
374
- info = @flickr.photos.search :user_id => "41650587@N02"
375
- photo info[0]
376
- end
377
-
378
- # photos.comments
379
- def test_photos_comments_getList
380
- comments = @flickr.photos.comments.getList :photo_id => "3839885270"
381
- assert_equal 1, comments.size
382
- assert_equal "3839885270", comments.photo_id
383
- assert_equal "41630239-3839885270-72157621986549875", comments[0].id
384
- assert_equal "41650587@N02", comments[0].author
385
- assert_equal "ruby_flickraw", comments[0].authorname
386
- assert_equal "https://www.flickr.com/photos/41650587@N02/3839885270/#comment72157621986549875", comments[0].permalink
387
- assert_equal "This is a cute cat !", comments[0].to_s
388
- end
389
-
390
- # tags
391
- def test_tags_getListPhoto
392
- tags = @flickr.tags.getListPhoto :photo_id => "3839885270"
393
- assert_equal 2, tags.tags.size
394
- assert_equal "3839885270", tags.id
395
- assert_equal %w{cat pet}, tags.tags.map { |t| t.to_s}.sort
396
- end
397
-
398
- def test_tags_getListUser
399
- tags = @flickr.tags.getListUser :user_id => "41650587@N02"
400
- assert_equal "41650587@N02", tags.id
401
- assert_equal %w{cat pet}, tags.tags.sort
402
- end
403
-
404
- # urls
405
- def test_urls_getGroup
406
- info = @flickr.urls.getGroup :group_id => "51035612836@N01"
407
- assert_equal "51035612836@N01", info.nsid
408
- assert_equal "https://www.flickr.com/groups/api/", info.url
409
- end
410
-
411
- def test_urls_getUserPhotos
412
- info = @flickr.urls.getUserPhotos :user_id => "41650587@N02"
413
- assert_equal "41650587@N02", info.nsid
414
- assert_equal "https://www.flickr.com/photos/41650587@N02/", info.url
415
- end
416
-
417
- def test_urls_getUserProfile
418
- info = @flickr.urls.getUserProfile :user_id => "41650587@N02"
419
- assert_equal "41650587@N02", info.nsid
420
- assert_equal "https://www.flickr.com/people/41650587@N02/", info.url
421
- end
422
-
423
- def test_urls_lookupGroup
424
- info = @flickr.urls.lookupGroup :url => "https://www.flickr.com/groups/api/"
425
- assert_equal "51035612836@N01", info.id
426
- assert_equal "Flickr API", info.groupname
427
- end
428
-
429
- def test_urls_lookupUser
430
- info = @flickr.urls.lookupUser :url => "https://www.flickr.com/photos/41650587@N02/"
431
- assert_equal "41650587@N02", info.id
432
- assert_equal "ruby_flickraw", info.username
433
- end
434
-
435
- def test_urls
436
- id = "3839885270"
437
- info = @flickr.photos.getInfo(:photo_id => id)
438
-
439
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06.jpg", Flickr.url(info)
440
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_m.jpg", Flickr.url_m(info)
441
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_s.jpg", Flickr.url_s(info)
442
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_t.jpg", Flickr.url_t(info)
443
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_b.jpg", Flickr.url_b(info)
444
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_z.jpg", Flickr.url_z(info)
445
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_q.jpg", Flickr.url_q(info)
446
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_n.jpg", Flickr.url_n(info)
447
- assert_equal "https://farm3.staticflickr.com/2485/3839885270_6fb8b54e06_c.jpg", Flickr.url_c(info)
448
-
449
- assert_equal "https://www.flickr.com/people/41650587@N02/", Flickr.url_profile(info)
450
- assert_equal "https://www.flickr.com/photos/41650587@N02/", Flickr.url_photostream(info)
451
- assert_equal "https://www.flickr.com/photos/41650587@N02/3839885270", Flickr.url_photopage(info)
452
- assert_equal "https://www.flickr.com/photos/41650587@N02/sets/", Flickr.url_photosets(info)
453
- assert_equal "https://flic.kr/p/6Rjq7s", Flickr.url_short(info)
454
- end
455
-
456
- def test_url_escape
457
- result_set = nil
458
- assert_nothing_raised {
459
- result_set = @flickr.photos.search :text => "family vacation"
460
- }
461
- assert_operator result_set.total.to_i, :>=, 0
462
-
463
- # Unicode tests
464
- echo = nil
465
- utf8_text = "Hélène François, €uro"
466
- assert_nothing_raised {
467
- echo = @flickr.test.echo :utf8_text => utf8_text
468
- }
469
- assert_equal echo.utf8_text, utf8_text
470
- end
471
- end
data/test/test_cache.rb DELETED
@@ -1,45 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- lib = File.dirname(__FILE__)
4
- $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'test/unit'
7
- require 'tempfile'
8
- require 'yaml'
9
- require 'benchmark'
10
-
11
- class TestCache < Test::Unit::TestCase
12
-
13
- def test_read_and_write
14
- ::Flickr.class_variable_set :@@initialized, false if ::Flickr.class_variable_get :@@initialized
15
-
16
- file = Tempfile.new(['flickr-gem-test', '.yml'])
17
- path = file.path
18
- file.close
19
- file.unlink
20
-
21
- refute File.exist? path
22
-
23
- ::Flickr.cache = path
24
-
25
- no_cache_timer = Benchmark.realtime do
26
- ::Flickr.new
27
- end
28
-
29
- assert File.exist? path
30
- from_disk = YAML.load_file path
31
- assert_equal Array, from_disk.class
32
- assert_equal 222, from_disk.count
33
- assert from_disk.all? { |x| /\Aflickr(\.(?i:[a-z]+))+\z/ === x }
34
-
35
- cache_timer = Benchmark.realtime do
36
- ::Flickr.new
37
- end
38
-
39
- assert_operator no_cache_timer, :>, cache_timer
40
- assert_operator 10, :<, no_cache_timer / cache_timer
41
-
42
- ensure
43
- File.unlink path
44
- end
45
- end