go-picasa-go 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +135 -0
- data/Rakefile +16 -0
- data/TODO +10 -0
- data/VERSION +1 -0
- data/bin/go-picasa-go +64 -0
- data/examples/rails-example/README +243 -0
- data/examples/rails-example/Rakefile +10 -0
- data/examples/rails-example/app/controllers/albums_controller.rb +62 -0
- data/examples/rails-example/app/controllers/application_controller.rb +10 -0
- data/examples/rails-example/app/controllers/photos_controller.rb +77 -0
- data/examples/rails-example/app/helpers/albums_helper.rb +9 -0
- data/examples/rails-example/app/helpers/application_helper.rb +3 -0
- data/examples/rails-example/app/models/my_user.rb +9 -0
- data/examples/rails-example/app/views/albums/_form.html.erb +15 -0
- data/examples/rails-example/app/views/albums/edit.html.erb +10 -0
- data/examples/rails-example/app/views/albums/index.html.erb +50 -0
- data/examples/rails-example/app/views/albums/new.html.erb +10 -0
- data/examples/rails-example/app/views/photos/index.html.erb +30 -0
- data/examples/rails-example/app/views/photos/new.html.erb +8 -0
- data/examples/rails-example/app/views/photos/show.html.erb +19 -0
- data/examples/rails-example/config/boot.rb +110 -0
- data/examples/rails-example/config/database.yml +22 -0
- data/examples/rails-example/config/environment.rb +42 -0
- data/examples/rails-example/config/environments/development.rb +17 -0
- data/examples/rails-example/config/environments/production.rb +28 -0
- data/examples/rails-example/config/environments/test.rb +28 -0
- data/examples/rails-example/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails-example/config/initializers/inflections.rb +10 -0
- data/examples/rails-example/config/initializers/mime_types.rb +5 -0
- data/examples/rails-example/config/initializers/new_rails_defaults.rb +21 -0
- data/examples/rails-example/config/initializers/session_store.rb +15 -0
- data/examples/rails-example/config/locales/en.yml +5 -0
- data/examples/rails-example/config/routes.rb +49 -0
- data/examples/rails-example/db/seeds.rb +7 -0
- data/examples/rails-example/doc/README_FOR_APP +2 -0
- data/examples/rails-example/log/development.log +6923 -0
- data/examples/rails-example/log/production.log +0 -0
- data/examples/rails-example/log/server.log +0 -0
- data/examples/rails-example/log/test.log +0 -0
- data/examples/rails-example/public/404.html +30 -0
- data/examples/rails-example/public/422.html +30 -0
- data/examples/rails-example/public/500.html +30 -0
- data/examples/rails-example/public/favicon.ico +0 -0
- data/examples/rails-example/public/images/rails.png +0 -0
- data/examples/rails-example/public/index.html +275 -0
- data/examples/rails-example/public/javascripts/application.js +2 -0
- data/examples/rails-example/public/javascripts/controls.js +963 -0
- data/examples/rails-example/public/javascripts/dragdrop.js +973 -0
- data/examples/rails-example/public/javascripts/effects.js +1128 -0
- data/examples/rails-example/public/javascripts/prototype.js +4320 -0
- data/examples/rails-example/public/robots.txt +5 -0
- data/examples/rails-example/script/about +4 -0
- data/examples/rails-example/script/console +3 -0
- data/examples/rails-example/script/dbconsole +3 -0
- data/examples/rails-example/script/destroy +3 -0
- data/examples/rails-example/script/generate +3 -0
- data/examples/rails-example/script/performance/benchmarker +3 -0
- data/examples/rails-example/script/performance/profiler +3 -0
- data/examples/rails-example/script/plugin +3 -0
- data/examples/rails-example/script/runner +3 -0
- data/examples/rails-example/script/server +3 -0
- data/examples/rails-example/test/functional/albums_controller_test.rb +8 -0
- data/examples/rails-example/test/performance/browsing_test.rb +9 -0
- data/examples/rails-example/test/test_helper.rb +38 -0
- data/examples/rails-example/test/unit/helpers/albums_helper_test.rb +4 -0
- data/go_picasa_go.gemspec +184 -0
- data/init.rb +1 -0
- data/lib/generators/authentication_token_generator.rb +12 -0
- data/lib/generators/template/user_class.erb +9 -0
- data/lib/generators/user_class_generator.rb +50 -0
- data/lib/go_picasa_go.rb +26 -0
- data/lib/patchs/object.rb +21 -0
- data/lib/patchs/ssl.rb +9 -0
- data/lib/picasa/album.rb +267 -0
- data/lib/picasa/authentication.rb +19 -0
- data/lib/picasa/default_album.rb +9 -0
- data/lib/picasa/default_photo.rb +6 -0
- data/lib/picasa/default_user.rb +6 -0
- data/lib/picasa/http/album.rb +113 -0
- data/lib/picasa/http/authentication.rb +40 -0
- data/lib/picasa/http/photo.rb +117 -0
- data/lib/picasa/missing.rb +22 -0
- data/lib/picasa/photo.rb +190 -0
- data/lib/picasa/template/album.xml.erb +20 -0
- data/lib/picasa/template/photo.erb +15 -0
- data/lib/picasa/user.rb +57 -0
- data/lib/picasa/util.rb +33 -0
- data/script.rb +46 -0
- data/spec/album_spec.rb +245 -0
- data/spec/authentication_spec.rb +19 -0
- data/spec/default_classes_spec.rb +50 -0
- data/spec/fixture/photo.jpg +0 -0
- data/spec/fixture/photo2.jpg +0 -0
- data/spec/generators/user_class_generator_spec.rb +40 -0
- data/spec/http/album_spec.rb +129 -0
- data/spec/http/authentication_spec.rb +15 -0
- data/spec/http/photo_spec.rb +78 -0
- data/spec/http_response_helper.rb +23 -0
- data/spec/mock_helper.rb +113 -0
- data/spec/photo_spec.rb +201 -0
- data/spec/spec_helper.rb +151 -0
- data/spec/suites/all.rb +14 -0
- data/spec/suites/all_mocked.rb +5 -0
- data/spec/user_spec.rb +74 -0
- metadata +222 -0
data/script.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'go_picasa_go'
|
3
|
+
|
4
|
+
|
5
|
+
class MeuUsuario
|
6
|
+
acts_as_picasa_user
|
7
|
+
has_many_picasa_albums :class_name => "MeuAlbum"
|
8
|
+
|
9
|
+
def picasa_id
|
10
|
+
'bandmanagertest'
|
11
|
+
end
|
12
|
+
|
13
|
+
def auth_token
|
14
|
+
"DQAAAHsAAAAdMyvdNfPg_iTFD-T_u6bBb-9BegOP7CGWnjah7FCJvnu8aiOoHXJMAJ-6HS_8vOE"+
|
15
|
+
"2zFLXaSzp3oe4mB9lJexTpxxM-CmChSTs-9OBd6nAwNji5yWnLUFv_Q7-ibXMx7820aFdnU7mr6"+
|
16
|
+
"qqvHUhXESdhBEnD1QP_o8dqsP-6T-oig"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class MeuAlbum
|
22
|
+
acts_as_picasa_album
|
23
|
+
belongs_to_picasa_user :class_name => "MeuUsuario"
|
24
|
+
end
|
25
|
+
|
26
|
+
class MinhaPhoto
|
27
|
+
acts_as_picasa_photo
|
28
|
+
belongs_to_picasa_album :class_name => "MeuAlbum"
|
29
|
+
end
|
30
|
+
|
31
|
+
@user = MeuUsuario.new
|
32
|
+
|
33
|
+
@album = MeuAlbum.new
|
34
|
+
@album.user = @user
|
35
|
+
@album.title = 'title'
|
36
|
+
@album.summary = 'summary'
|
37
|
+
@album.location = 'location'
|
38
|
+
@album.keywords = 'keywords'
|
39
|
+
@album.access = 'public'
|
40
|
+
@album.picasa_save!
|
41
|
+
|
42
|
+
@photo = MinhaPhoto.new
|
43
|
+
@photo.album = @album
|
44
|
+
@photo.summary = 'summary'
|
45
|
+
@photo.file = File.open 'spec/fixture/photo.jpg', 'r'
|
46
|
+
@photo.picasa_save!
|
data/spec/album_spec.rb
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::Album' do
|
4
|
+
|
5
|
+
it 'should save a new album' do
|
6
|
+
mock_authentication
|
7
|
+
mock_post_album
|
8
|
+
mock_get_album
|
9
|
+
mock_update_album :title => 'title'
|
10
|
+
|
11
|
+
user = UserObject.new
|
12
|
+
|
13
|
+
album = AlbumObject.new
|
14
|
+
album.user = user
|
15
|
+
album.title = "Album Title"
|
16
|
+
album.summary = "Album Summary"
|
17
|
+
album.location = "Album location"
|
18
|
+
album.keywords = "Album keywords"
|
19
|
+
|
20
|
+
album.picasa_save!
|
21
|
+
album.picasa_save.should be_true
|
22
|
+
|
23
|
+
album.instance_variables.each do |var_name|
|
24
|
+
value = album.instance_variable_get var_name
|
25
|
+
value.should_not be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not save a new album if cannot authenticate' do
|
30
|
+
mock_authentication_failure
|
31
|
+
|
32
|
+
album = AlbumObject.new
|
33
|
+
album.title = "Album Title"
|
34
|
+
album.summary = "Album Summary"
|
35
|
+
album.location = "Album location"
|
36
|
+
album.keywords = "Album keywords"
|
37
|
+
|
38
|
+
album.stub!(:auth_token).and_return("invalid_token")
|
39
|
+
|
40
|
+
lambda { album.picasa_save! }.should raise_error
|
41
|
+
album.picasa_save.should be_false
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should find an album by id' do
|
45
|
+
mock_authentication
|
46
|
+
mock_post_album
|
47
|
+
mock_get_album
|
48
|
+
|
49
|
+
auth_token = login
|
50
|
+
album_id = post_album
|
51
|
+
album = AlbumObject.picasa_find 'bandmanagertest', album_id, auth_token
|
52
|
+
|
53
|
+
album.should_not be_nil
|
54
|
+
album.picasa_id.should == album_id
|
55
|
+
|
56
|
+
album.user.should_not be_nil
|
57
|
+
album.user.picasa_id.should_not be_nil
|
58
|
+
album.user.picasa_id.should_not be_empty
|
59
|
+
|
60
|
+
album.title.size.should > 0
|
61
|
+
album.summary.size.should > 0
|
62
|
+
album.location.size.should > 0
|
63
|
+
album.access.size.should > 0
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should get nil if album is not found' do
|
67
|
+
mock_authentication
|
68
|
+
mock_get_album_failure
|
69
|
+
|
70
|
+
auth_token = login
|
71
|
+
album = AlbumObject.picasa_find 'bandmanagertest', "0989", auth_token
|
72
|
+
album.should be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should find all albums from an user' do
|
76
|
+
mock_authentication
|
77
|
+
mock_post_album
|
78
|
+
mock_get_albums
|
79
|
+
|
80
|
+
auth_token = login
|
81
|
+
post_album # Create one album
|
82
|
+
albums = AlbumObject.picasa_find_all 'bandmanagertest', auth_token
|
83
|
+
albums.should_not be_nil
|
84
|
+
albums.size.should > 0
|
85
|
+
|
86
|
+
albums.each do |album|
|
87
|
+
album.user.should_not be_nil
|
88
|
+
album.user.picasa_id.should_not be_nil
|
89
|
+
album.user.picasa_id.should_not be_empty
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should update the title attribute from an album' do
|
94
|
+
mock_authentication
|
95
|
+
mock_post_album
|
96
|
+
|
97
|
+
title1 = "Another title1"
|
98
|
+
title2 = "Another title2"
|
99
|
+
|
100
|
+
mock_update_album :title => title1, :access => 'private'
|
101
|
+
|
102
|
+
album = create_album
|
103
|
+
|
104
|
+
album.picasa_update_attributes! :title => title1, :access => 'private'
|
105
|
+
album.title.should == title1
|
106
|
+
album.access.should == 'private'
|
107
|
+
|
108
|
+
mock_update_album :title => title2
|
109
|
+
|
110
|
+
album.picasa_update_attributes(:title => title2).should be_true
|
111
|
+
album.title.should == title2
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should update an album' do
|
115
|
+
mock_authentication
|
116
|
+
mock_post_album
|
117
|
+
|
118
|
+
title1 = "Another title1"
|
119
|
+
title2 = "Another title2"
|
120
|
+
|
121
|
+
mock_update_album :title => title1
|
122
|
+
|
123
|
+
album = create_album
|
124
|
+
album.title = title1
|
125
|
+
|
126
|
+
album.picasa_update!
|
127
|
+
album.title.should == title1
|
128
|
+
|
129
|
+
mock_update_album :title => title2
|
130
|
+
|
131
|
+
album.title = title2
|
132
|
+
|
133
|
+
album.picasa_update.should be_true
|
134
|
+
album.title.should == title2
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should destroy an album' do
|
138
|
+
mock_authentication
|
139
|
+
mock_post_album
|
140
|
+
mock_delete_album
|
141
|
+
mock_get_album_failure
|
142
|
+
|
143
|
+
album = create_album
|
144
|
+
album.picasa_destroy
|
145
|
+
|
146
|
+
auth_token = login
|
147
|
+
AlbumObject.picasa_find('bandmanagertest', album.picasa_id, auth_token).should be_nil
|
148
|
+
|
149
|
+
album = create_album
|
150
|
+
album.picasa_destroy.should be_true
|
151
|
+
|
152
|
+
auth_token = login
|
153
|
+
AlbumObject.picasa_find('bandmanagertest', album.picasa_id, auth_token).should be_nil
|
154
|
+
album = create_album
|
155
|
+
album.picasa_destroy!
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should have the method user_class' do
|
159
|
+
AlbumObject.user_class
|
160
|
+
|
161
|
+
album = AlbumObject.new
|
162
|
+
album.user_class
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should get all photos from an album' do
|
166
|
+
mock_authentication
|
167
|
+
mock_post_album
|
168
|
+
mock_get_album
|
169
|
+
mock_post_photo
|
170
|
+
mock_get_photos
|
171
|
+
|
172
|
+
photo = create_photo
|
173
|
+
|
174
|
+
album = photo.album
|
175
|
+
photos = album.photos
|
176
|
+
photos.should_not be_nil
|
177
|
+
photos.size.should > 0
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should get one specific photo from an album' do
|
181
|
+
mock_authentication
|
182
|
+
mock_post_album
|
183
|
+
mock_get_album
|
184
|
+
mock_post_photo
|
185
|
+
mock_get_photo
|
186
|
+
mock_download_image
|
187
|
+
|
188
|
+
photo = create_photo
|
189
|
+
|
190
|
+
album = photo.album
|
191
|
+
photo2 = album.find_photo photo.picasa_id
|
192
|
+
photo2.should_not be_nil
|
193
|
+
photo2.picasa_id.should == photo.picasa_id
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should only uptade an album if it already exists when calling save method' do
|
197
|
+
mock_authentication
|
198
|
+
mock_post_album
|
199
|
+
mock_get_album
|
200
|
+
mock_get_albums
|
201
|
+
mock_post_photo
|
202
|
+
mock_get_photo
|
203
|
+
mock_update_album :title => 'Changing title'
|
204
|
+
mock_download_image
|
205
|
+
|
206
|
+
user = UserObject.new
|
207
|
+
|
208
|
+
album = AlbumObject.new
|
209
|
+
album.user = user
|
210
|
+
album.title = "Album Title"
|
211
|
+
|
212
|
+
album.picasa_save.should be_true
|
213
|
+
num_albums = user.albums.size
|
214
|
+
|
215
|
+
album.title = 'Changing title'
|
216
|
+
album.picasa_save.should be_true
|
217
|
+
|
218
|
+
user.albums(true).size.should == num_albums
|
219
|
+
album2 = user.find_album album.picasa_id
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should have the methods shortcuts" do
|
223
|
+
mock_authentication
|
224
|
+
mock_post_album
|
225
|
+
mock_get_album
|
226
|
+
mock_get_albums
|
227
|
+
mock_post_photo
|
228
|
+
mock_get_photo
|
229
|
+
mock_delete_album
|
230
|
+
mock_update_album :title => 'Changing title'
|
231
|
+
mock_download_image
|
232
|
+
|
233
|
+
album = create_album
|
234
|
+
|
235
|
+
album.save
|
236
|
+
album.save!
|
237
|
+
album.update
|
238
|
+
album.update!
|
239
|
+
album.update_attributes
|
240
|
+
album.update_attributes!
|
241
|
+
album.destroy
|
242
|
+
album.destroy!
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::Authentication' do
|
4
|
+
it 'should authenticate user returning the authorization token' do
|
5
|
+
mock_authentication
|
6
|
+
|
7
|
+
auth_token = Picasa::Authentication.authenticate 'bandmanagertest', '$bandmanager$'
|
8
|
+
auth_token.should_not be_nil
|
9
|
+
auth_token.should_not be_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should raise an exception in casa of authorization failure' do
|
13
|
+
mock_authentication_failure
|
14
|
+
|
15
|
+
lambda {
|
16
|
+
Picasa::Authentication.authenticate 'bandmanagertest', 'wrong_password'
|
17
|
+
}.should raise_error
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::Album' do
|
4
|
+
|
5
|
+
class MyUser < Picasa::DefaultUser
|
6
|
+
def picasa_id
|
7
|
+
"bandmanagertest"
|
8
|
+
end
|
9
|
+
|
10
|
+
def auth_token
|
11
|
+
"DQAAAHsAAAAdMyvdNfPg_iTFD-T_u6bBb-9BegOP7CGWnjah7FCJvnu8aiOoHXJMAJ-6HS_8vOE"+
|
12
|
+
"2zFLXaSzp3oe4mB9lJexTpxxM-CmChSTs-9OBd6nAwNji5yWnLUFv_Q7-ibXMx7820aFdnU7mr6"+
|
13
|
+
"qqvHUhXESdhBEnD1QP_o8dqsP-6T-oig"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it 'should be able to instantiate an user and start using go picasa go' do
|
19
|
+
mock_authentication
|
20
|
+
mock_post_album
|
21
|
+
mock_get_albums
|
22
|
+
mock_get_album
|
23
|
+
mock_post_photo
|
24
|
+
mock_get_photos
|
25
|
+
mock_get_photo
|
26
|
+
|
27
|
+
user = MyUser.new
|
28
|
+
user.album_class.should == Picasa::DefaultAlbum
|
29
|
+
|
30
|
+
album = Picasa::DefaultAlbum.new
|
31
|
+
album.title = 'Title'
|
32
|
+
album.user = user
|
33
|
+
album.picasa_save.should be_true
|
34
|
+
|
35
|
+
photo = Picasa::DefaultPhoto.new
|
36
|
+
photo.summary = 'summary'
|
37
|
+
photo.file = File.open 'spec/fixture/photo.jpg', 'r'
|
38
|
+
photo.album = album
|
39
|
+
photo.picasa_save.should be_true
|
40
|
+
|
41
|
+
albums = user.albums
|
42
|
+
albums.should_not be_nil
|
43
|
+
albums.size.should > 0
|
44
|
+
|
45
|
+
photos = albums.first.photos
|
46
|
+
photos.should_not be_nil
|
47
|
+
photos.size.should > 0
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'UserClassGenerator' do
|
4
|
+
|
5
|
+
FILE_NAME = 'my_user.rb'
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
mock_authentication
|
9
|
+
if File.exist? FILE_NAME
|
10
|
+
File.delete FILE_NAME
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should generate the user class file' do
|
15
|
+
dir = Dir.open '.'
|
16
|
+
dir.entries.should_not include 'my_user.rb'
|
17
|
+
|
18
|
+
system "go-picasa-go user_class MyUser bandmanagertest '$bandmanager$'"
|
19
|
+
|
20
|
+
dir.entries.should include 'my_user.rb'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should not generate the user class if it doesnt inform the right parameters' do
|
24
|
+
dir = Dir.open '.'
|
25
|
+
dir.entries.should_not include 'my_user.rb'
|
26
|
+
|
27
|
+
system "go-picasa-go user_class MyUser bandmanagertest"
|
28
|
+
|
29
|
+
dir.entries.should_not include 'my_user.rb'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not generate the user class if it cannot authenticate' do
|
33
|
+
dir = Dir.open '.'
|
34
|
+
dir.entries.should_not include 'my_user.rb'
|
35
|
+
|
36
|
+
system "go-picasa-go user_class MyUser bandmanagertest wrong_password"
|
37
|
+
|
38
|
+
dir.entries.should_not include 'my_user.rb'
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::HTTP::Album' do
|
4
|
+
include Picasa::Util
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
delete_all_albums
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should do a post to create a album for a user' do
|
11
|
+
params = {
|
12
|
+
:title => 'testing title',
|
13
|
+
:summary => 'testing summary',
|
14
|
+
:location => 'testing location',
|
15
|
+
:keywords => 'testing keywords'
|
16
|
+
}
|
17
|
+
|
18
|
+
auth_token = login
|
19
|
+
resp, body = Picasa::HTTP::Album.post_album 'bandmanagertest', auth_token, params
|
20
|
+
resp.success?.should be_true
|
21
|
+
resp.message.should == "Created"
|
22
|
+
|
23
|
+
body.should_not be_nil
|
24
|
+
body.should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create a private album' do
|
28
|
+
params = {
|
29
|
+
:title => 'testing title',
|
30
|
+
:summary => 'testing summary',
|
31
|
+
:location => 'testing location',
|
32
|
+
:keywords => 'testing keywords',
|
33
|
+
:access => 'private'
|
34
|
+
}
|
35
|
+
|
36
|
+
auth_token = login
|
37
|
+
resp, body = Picasa::HTTP::Album.post_album 'bandmanagertest', auth_token, params
|
38
|
+
resp.success?.should be_true
|
39
|
+
resp.message.should == "Created"
|
40
|
+
|
41
|
+
body.should_not be_nil
|
42
|
+
body.should_not be_empty
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should do a post request to update an album' do
|
46
|
+
album_id = post_album
|
47
|
+
auth_token = login
|
48
|
+
|
49
|
+
params = {
|
50
|
+
:title => 'testing title2',
|
51
|
+
:summary => 'testing summary2',
|
52
|
+
:location => 'testing location2',
|
53
|
+
:keywords => 'testing keywords2'
|
54
|
+
}
|
55
|
+
|
56
|
+
album_id = post_album
|
57
|
+
|
58
|
+
resp, body = Picasa::HTTP::Album.update_album "bandmanagertest", album_id, auth_token, params
|
59
|
+
resp.success?.should be_true
|
60
|
+
resp.message_OK?.should be_true
|
61
|
+
|
62
|
+
body.should_not be_nil
|
63
|
+
body.should_not be_empty
|
64
|
+
|
65
|
+
doc = Nokogiri::XML body
|
66
|
+
|
67
|
+
doc.at_css('title').content.should == params[:title]
|
68
|
+
doc.at_css('summary').content.should == params[:summary]
|
69
|
+
doc.at_xpath('//gphoto:location').content.should == params[:location]
|
70
|
+
doc.at_xpath('//media:keywords').attribute("value") == params[:keywords]
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should do a get to retrieve all albums from user' do
|
74
|
+
auth_token = login
|
75
|
+
resp, body = Picasa::HTTP::Album.get_albums 'bandmanagertest', auth_token
|
76
|
+
resp.success?.should be_true
|
77
|
+
resp.message.should == "OK"
|
78
|
+
|
79
|
+
body.should_not be_nil
|
80
|
+
body.should_not be_empty
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should do a get to retrieve one album from a user' do
|
84
|
+
album_id = post_album
|
85
|
+
|
86
|
+
auth_token = login
|
87
|
+
resp, body = Picasa::HTTP::Album.get_album "bandmanagertest", album_id, auth_token
|
88
|
+
resp.success?.should be_true
|
89
|
+
resp.message_OK?.should be_true
|
90
|
+
|
91
|
+
body.should_not be_nil
|
92
|
+
body.should_not be_empty
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should retrieve a public album with no authentication token' do
|
96
|
+
album_id = post_album :access => 'public'
|
97
|
+
|
98
|
+
auth_token = login
|
99
|
+
resp, body = Picasa::HTTP::Album.get_album "bandmanagertest", album_id
|
100
|
+
resp.success?.should be_true
|
101
|
+
resp.message_OK?.should be_true
|
102
|
+
|
103
|
+
body.should_not be_nil
|
104
|
+
body.should_not be_empty
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should get 404 if try to retrieve an private album without authorization' do
|
108
|
+
album_id = post_album :access => 'private'
|
109
|
+
|
110
|
+
auth_token = login
|
111
|
+
resp, body = Picasa::HTTP::Album.get_album "bandmanagertest", album_id
|
112
|
+
resp.should_not be_success
|
113
|
+
resp.code.should == '404'
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should do a delete request to delete an album from a user' do
|
117
|
+
album_id = post_album
|
118
|
+
|
119
|
+
auth_token = login
|
120
|
+
resp, body = Picasa::HTTP::Album.delete_album "bandmanagertest", album_id, auth_token
|
121
|
+
resp.success?.should be_true
|
122
|
+
resp.message_OK?.should be_true
|
123
|
+
|
124
|
+
resp, body = Picasa::HTTP::Album.get_album "bandmanagertest", album_id, auth_token
|
125
|
+
resp.success?.should_not be_true
|
126
|
+
resp.message.should == "Not Found"
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|