flickr 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +185 -0
- data/examples/auth.rb +22 -0
- data/examples/interestingness.rb +7 -0
- data/examples/search.rb +20 -0
- data/examples/sinatra.rb +31 -0
- data/examples/upload.rb +16 -0
- data/examples/web_oauth.rb +47 -0
- data/flickr_rdoc.rb +128 -0
- data/lib/flickr.rb +281 -0
- data/lib/flickr/errors.rb +15 -0
- data/lib/flickr/oauth_client.rb +175 -0
- data/lib/flickr/request.rb +7 -0
- data/lib/flickr/response.rb +38 -0
- data/lib/flickr/response_list.rb +29 -0
- data/lib/flickr/util.rb +13 -0
- data/lib/flickr/version.rb +3 -0
- data/rakefile +22 -0
- data/test/test.rb +471 -0
- data/test/test_cache.rb +45 -0
- data/test/test_request.rb +36 -0
- data/test/test_response.rb +30 -0
- data/test/test_upload.rb +41 -0
- metadata +103 -53
- data/Rakefile +0 -36
- data/flickr.rb +0 -501
- data/index.html +0 -129
- data/test_flickr.rb +0 -173
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class Flickr
|
|
2
|
+
class Response
|
|
3
|
+
|
|
4
|
+
attr_reader :flickr_type
|
|
5
|
+
|
|
6
|
+
def self.build(h, type) # :nodoc:
|
|
7
|
+
if h.is_a? Response
|
|
8
|
+
h
|
|
9
|
+
elsif type =~ /s$/ and (a = h[$`]).is_a? Array
|
|
10
|
+
ResponseList.new(h, type, a.collect { |e| Response.build(e, $`) })
|
|
11
|
+
elsif h.keys == ['_content']
|
|
12
|
+
h['_content']
|
|
13
|
+
else
|
|
14
|
+
Response.new(h, type)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(h, type) # :nodoc:
|
|
19
|
+
@flickr_type, @h = type, {}
|
|
20
|
+
methods = 'class << self;'
|
|
21
|
+
h.each do |k, v|
|
|
22
|
+
@h[k] = case v
|
|
23
|
+
when Hash then Response.build(v, k)
|
|
24
|
+
when Array then v.collect { |e| Response.build(e, k) }
|
|
25
|
+
else v
|
|
26
|
+
end
|
|
27
|
+
methods << "def #{k}; @h['#{k}'] end;" if Util.safe_for_eval?(k)
|
|
28
|
+
end
|
|
29
|
+
eval methods << 'end'
|
|
30
|
+
end
|
|
31
|
+
def [](k); @h[k] end
|
|
32
|
+
def to_s; @h['_content'] || super end
|
|
33
|
+
def inspect; @h.inspect end
|
|
34
|
+
def to_hash; @h end
|
|
35
|
+
def marshal_dump; [@h, @flickr_type] end
|
|
36
|
+
def marshal_load(data); initialize(*data) end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class Flickr
|
|
2
|
+
class ResponseList < Response
|
|
3
|
+
|
|
4
|
+
include Enumerable
|
|
5
|
+
|
|
6
|
+
def initialize(h, t, a); super(h, t); @a = a end
|
|
7
|
+
|
|
8
|
+
def [](k); k.is_a?(Integer) ? @a[k] : super(k) end
|
|
9
|
+
|
|
10
|
+
def each
|
|
11
|
+
@a.each { |e| yield e }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_a; @a end
|
|
15
|
+
|
|
16
|
+
def inspect; @a.inspect end
|
|
17
|
+
|
|
18
|
+
def size; @a.size end
|
|
19
|
+
|
|
20
|
+
def map!
|
|
21
|
+
@a = @a.map { |e| yield e }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def marshal_dump; [@h, @flickr_type, @a] end
|
|
25
|
+
|
|
26
|
+
alias length size
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/flickr/util.rb
ADDED
data/rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rake/clean'
|
|
2
|
+
require 'rdoc/task'
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
|
|
5
|
+
lib = File.expand_path('../lib/', __FILE__)
|
|
6
|
+
$:.unshift lib unless $:.include?(lib)
|
|
7
|
+
|
|
8
|
+
require 'flickr'
|
|
9
|
+
require './flickr_rdoc'
|
|
10
|
+
|
|
11
|
+
Rake::RDocTask.new do |rd|
|
|
12
|
+
rd.main = "README.rdoc"
|
|
13
|
+
rd.rdoc_files.include "README.rdoc", "lib/flickr.rb"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Rake::TestTask.new do |t|
|
|
17
|
+
t.warning = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
task :console do
|
|
21
|
+
exec 'pry -I ./lib -r flickr'
|
|
22
|
+
end
|
data/test/test.rb
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
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
|