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
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::HTTP::Authentication' do
|
4
|
+
include Picasa::Util
|
5
|
+
|
6
|
+
it 'should do a post to authenticate' do
|
7
|
+
resp, body = Picasa::HTTP::Authentication.authenticate 'bandmanagertest@gmail.com', '$bandmanager$'
|
8
|
+
resp.success?.should be_true
|
9
|
+
resp.message_OK?.should be_true
|
10
|
+
|
11
|
+
auth_token = extract_auth_token body
|
12
|
+
auth_token.should_not be_nil
|
13
|
+
auth_token.should_not be_empty
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Picasa::HTTP::Photo' do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
delete_all_albums
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should get all photos from an album' do
|
10
|
+
auth_token = login
|
11
|
+
album_id = post_album
|
12
|
+
|
13
|
+
resp, data = Picasa::HTTP::Photo.get_photos 'bandmanagertest', album_id, auth_token
|
14
|
+
|
15
|
+
resp.should be_success
|
16
|
+
data.should_not be_nil
|
17
|
+
data.should_not be_empty
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should get one photo from an album' do
|
21
|
+
auth_token = login
|
22
|
+
album_id, photo_id = post_photo
|
23
|
+
|
24
|
+
resp, data = Picasa::HTTP::Photo.get_photo 'bandmanagertest', album_id, photo_id, auth_token
|
25
|
+
|
26
|
+
resp.should be_success
|
27
|
+
data.should_not be_nil
|
28
|
+
data.should_not be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should post a photo' do
|
32
|
+
album_id = post_album
|
33
|
+
auth_token = login
|
34
|
+
|
35
|
+
file = File.open 'spec/fixture/photo.jpg'
|
36
|
+
|
37
|
+
resp, data = Picasa::HTTP::Photo.post_photo(
|
38
|
+
'bandmanagertest', album_id, auth_token, "Summary", file
|
39
|
+
)
|
40
|
+
|
41
|
+
resp.code.should == "201"
|
42
|
+
resp.message.should == "Created"
|
43
|
+
data.should_not be_nil
|
44
|
+
data.should_not be_empty
|
45
|
+
|
46
|
+
doc = Nokogiri::XML data
|
47
|
+
doc.at_css('title').content.should == File.basename(file.path)
|
48
|
+
doc.at_css('summary').content.should == "Summary"
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should do a delete request to delete a photo from an album' do
|
52
|
+
album_id, photo_id, auth_token = post_photo
|
53
|
+
|
54
|
+
resp, data = Picasa::HTTP::Photo.delete_photo('bandmanagertest', album_id, photo_id, auth_token)
|
55
|
+
resp.should be_success
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should do a put request to update a photo' do
|
59
|
+
album_id, photo_id, auth_token = post_photo
|
60
|
+
|
61
|
+
file = File.open 'spec/fixture/photo2.jpg'
|
62
|
+
|
63
|
+
|
64
|
+
resp, data = Picasa::HTTP::Photo.update_photo(
|
65
|
+
'bandmanagertest', album_id, photo_id, auth_token, "SummaryUpdated", file
|
66
|
+
)
|
67
|
+
|
68
|
+
resp.code.should == "200"
|
69
|
+
resp.message.should == "OK"
|
70
|
+
data.should_not be_nil
|
71
|
+
data.should_not be_empty
|
72
|
+
|
73
|
+
doc = Nokogiri::XML data
|
74
|
+
doc.at_css('title').content.should == File.basename(file.path)
|
75
|
+
doc.at_css('summary').content.should == "SummaryUpdated"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Net
|
2
|
+
class HTTPResponse
|
3
|
+
SUCCESS_CODES = 200..206
|
4
|
+
|
5
|
+
def success?
|
6
|
+
SUCCESS_CODES.include? self.code.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
def message? msg
|
10
|
+
self.message == msg
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(m, *args, &block)
|
14
|
+
m = m.to_s
|
15
|
+
if m =~ /message_/
|
16
|
+
msg = m.split("_")[1].gsub('?','')
|
17
|
+
return message? msg
|
18
|
+
else
|
19
|
+
raise NoMethodError.new "undefined method #{m} for #{self.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/mock_helper.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
module MockHelper
|
2
|
+
def mock_authentication
|
3
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
4
|
+
"SID=DQAAAHgAAAAPNCL6mdI-GHhLWNxobTWfGwlWtFFVjZDatJrrcdx6UxlaP4WCll4yj0c_"+
|
5
|
+
"JEHcEp6RhracBN5ZYLhtmwpOgzMy4FlpJnNTuBAYwaraMmYdGIHBTqQKlOXTFHj-_igz9bF5v"+
|
6
|
+
"VaTOKM1r4VC4DOVadpad81CH86sWw6rzjNbRluYiw\nLSID=DQAAAHsAAABUvbolIC84hXe4_"+
|
7
|
+
"1zu17gr4ZkReQJvsnWyI5Ntivn4VfNaXClPbafabGnT11_gWOahnzmYL0YubbAlos6pghoXwVp"+
|
8
|
+
"68RswbHlWMj3mC0e5UnqpHBZmUkljb5FXjt-XfhRAYkGjxB1LqPre3wcAPSWaoB-nJjoRS2yI6"+
|
9
|
+
"lHoqDTjWA\nAuth="+
|
10
|
+
"DQAAAHsAAAAdMyvdNfPg_iTFD-T_u6bBb-9BegOP7CGWnjah7FCJvnu8aiOoHXJMAJ-6HS_8vOE"+
|
11
|
+
"2zFLXaSzp3oe4mB9lJexTpxxM-CmChSTs-9OBd6nAwNji5yWnLUFv_Q7-ibXMx7820aFdnU7mr6"+
|
12
|
+
"qqvHUhXESdhBEnD1QP_o8dqsP-6T-oig"
|
13
|
+
|
14
|
+
Picasa::HTTP::Authentication.stub!(:authenticate).and_return(resp_arr)
|
15
|
+
end
|
16
|
+
|
17
|
+
def mock_authentication_failure
|
18
|
+
resp_arr = build_resp_mock_array "403", "Forbidden", "Error=BadAuthentication\n"
|
19
|
+
Picasa::HTTP::Authentication.stub!(:authenticate).and_return(resp_arr)
|
20
|
+
end
|
21
|
+
|
22
|
+
def mock_post_album
|
23
|
+
resp_arr = build_resp_mock_array "201", "Created",
|
24
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881</id><published>2010-10-02T21:29:41.000Z</published><updated>2010-10-02T21:29:41.409Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/><title type='text'>testing title</title><summary type='text'>testing summary</summary><rights type='text'>public</rights><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/1'/><link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/acl'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><gphoto:id>5523564086023148881</gphoto:id><gphoto:name>TestingTitle</gphoto:name><gphoto:location>testing location</gphoto:location><gphoto:access>public</gphoto:access><gphoto:timestamp>1286054981000</gphoto:timestamp><gphoto:numphotos>0</gphoto:numphotos><gphoto:numphotosremaining>1000</gphoto:numphotosremaining><gphoto:bytesUsed>0</gphoto:bytesUsed><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><media:group><media:content url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/TestingTitle.jpg' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>testing summary</media:description><media:keywords/><media:thumbnail url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/s160-c/TestingTitle.jpg' height='160' width='160'/><media:title type='plain'>testing title</media:title></media:group></entry>"
|
25
|
+
|
26
|
+
Picasa::HTTP::Album.stub!(:post_album).and_return(resp_arr)
|
27
|
+
end
|
28
|
+
|
29
|
+
def mock_get_album
|
30
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
31
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881</id><published>2010-10-02T21:29:41.000Z</published><updated>2010-10-02T21:29:41.409Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/><title type='text'>testing title</title><summary type='text'>testing summary</summary><rights type='text'>public</rights><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/1'/><link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/acl'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><gphoto:id>5523564086023148881</gphoto:id><gphoto:name>TestingTitle</gphoto:name><gphoto:location>testing location</gphoto:location><gphoto:access>public</gphoto:access><gphoto:timestamp>1286054981000</gphoto:timestamp><gphoto:numphotos>0</gphoto:numphotos><gphoto:numphotosremaining>1000</gphoto:numphotosremaining><gphoto:bytesUsed>0</gphoto:bytesUsed><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><media:group><media:content url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/TestingTitle.jpg' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>testing summary</media:description><media:keywords/><media:thumbnail url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/s160-c/TestingTitle.jpg' height='160' width='160'/><media:title type='plain'>testing title</media:title></media:group></entry>"
|
32
|
+
|
33
|
+
Picasa::HTTP::Album.stub!(:get_album).and_return(resp_arr)
|
34
|
+
end
|
35
|
+
|
36
|
+
def mock_get_albums
|
37
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
38
|
+
"<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>http://picasaweb.google.com/data/feed/api/user/bandmanagertest</id><updated>2010-10-05T00:37:00.546Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#user'/><title type='text'>bandmanagertest</title><subtitle type='text'/><icon>http://www.google.com/profiles/c/u/0/static/images/NoPicture.gif?sz=64</icon><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest'/><link rel='http://schemas.google.com/photos/2007#slideshow' type='application/x-shockwave-flash' href='http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fbandmanagertest%3Falt%3Drss'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest?start-index=1&max-results=1000'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><generator version='1.00' uri='http://picasaweb.google.com/'>Picasaweb</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>1000</openSearch:itemsPerPage><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:thumbnail>http://www.google.com/profiles/c/u/0/static/images/NoPicture.gif?sz=64</gphoto:thumbnail><gphoto:quotalimit>1073741824</gphoto:quotalimit><gphoto:quotacurrent>0</gphoto:quotacurrent><gphoto:maxPhotosPerAlbum>1000</gphoto:maxPhotosPerAlbum><entry><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5524354526820046433</id><published>2010-10-05T00:36:59.000Z</published><updated>2010-10-05T00:37:00.546Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/><title type='text'>testing title</title><summary type='text'>testing summary</summary><rights type='text'>public</rights><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5524354526820046433'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5524354526820046433'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5524354526820046433/1'/><link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5524354526820046433/acl'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><gphoto:id>5524354526820046433</gphoto:id><gphoto:name>TestingTitle</gphoto:name><gphoto:location>testing location</gphoto:location><gphoto:access>public</gphoto:access><gphoto:timestamp>1286239019000</gphoto:timestamp><gphoto:numphotos>0</gphoto:numphotos><gphoto:numphotosremaining>1000</gphoto:numphotosremaining><gphoto:bytesUsed>0</gphoto:bytesUsed><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><media:group><media:content url='http://lh4.ggpht.com/_Eo7DPaDqPZg/TKpzLEBuFmE/AAAAAAAAA7A/tqUs5ChhYiI/TestingTitle.jpg' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>testing summary</media:description><media:keywords/><media:thumbnail url='http://lh4.ggpht.com/_Eo7DPaDqPZg/TKpzLEBuFmE/AAAAAAAAA7A/tqUs5ChhYiI/s160-c/TestingTitle.jpg' height='160' width='160'/><media:title type='plain'>testing title</media:title></media:group></entry></feed>"
|
39
|
+
|
40
|
+
Picasa::HTTP::Album.stub!(:get_albums).and_return(resp_arr)
|
41
|
+
end
|
42
|
+
|
43
|
+
def mock_get_album_failure
|
44
|
+
resp_arr = build_resp_mock_array "404", "NotFound", "Error=NotFound\n", false
|
45
|
+
Picasa::HTTP::Album.stub!(:get_album).and_return(resp_arr)
|
46
|
+
end
|
47
|
+
|
48
|
+
def mock_update_album params
|
49
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
50
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881</id><published>2010-10-02T21:29:41.000Z</published><updated>2010-10-02T21:29:41.409Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/><title type='text'>#{params[:title]}</title><summary type='text'>#{params[:summary]}</summary><rights type='text'>public</rights><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/1'/><link rel='http://schemas.google.com/acl/2007#accessControlList' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5523564086023148881/acl'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><gphoto:id>5523564086023148881</gphoto:id><gphoto:name>TestingTitle</gphoto:name><gphoto:location>#{params[:location]}</gphoto:location><gphoto:access>#{params[:access]}</gphoto:access><gphoto:timestamp>1286054981000</gphoto:timestamp><gphoto:numphotos>0</gphoto:numphotos><gphoto:numphotosremaining>1000</gphoto:numphotosremaining><gphoto:bytesUsed>0</gphoto:bytesUsed><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><media:group><media:content url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/TestingTitle.jpg' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>testing summary</media:description><media:keywords/><media:thumbnail url='http://lh3.ggpht.com/_Eo7DPaDqPZg/TKekRWmD1VE/AAAAAAAAAxw/uc_G0pxsLb4/s160-c/TestingTitle.jpg' height='160' width='160'/><media:title type='plain'>testing title</media:title></media:group></entry>"
|
51
|
+
|
52
|
+
Picasa::HTTP::Album.stub!(:update_album).and_return(resp_arr)
|
53
|
+
end
|
54
|
+
|
55
|
+
def mock_delete_album
|
56
|
+
resp_arr = build_resp_mock_array "200", "OK", ""
|
57
|
+
Picasa::HTTP::Album.stub!(:delete_album).and_return(resp_arr)
|
58
|
+
end
|
59
|
+
|
60
|
+
def mock_post_photo
|
61
|
+
resp_arr = build_resp_mock_array "201", "Created",
|
62
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258</id><published>2010-10-09T18:34:52.000Z</published><updated>2010-10-09T18:34:52.144Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'/><title type='text'>photo.jpg</title><summary type='text'>Summary</summary><content type='image/jpeg' src='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle#5526116634788894258'/><link rel='http://schemas.google.com/photos/2007#canonical' type='text/html' href='http://picasaweb.google.com/lh/photo/RQzOtdWIzuC4uSDK8LaGqg'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='edit-media' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='media-edit' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='http://picasaweb.google.com/lh/reportAbuse?uname=bandmanagertest&aid=5526116602627358369&iid=5526116634788894258'/><gphoto:id>5526116634788894258</gphoto:id><gphoto:version>1</gphoto:version><gphoto:albumid>5526116602627358369</gphoto:albumid><gphoto:access>public</gphoto:access><gphoto:width>1181</gphoto:width><gphoto:height>1181</gphoto:height><gphoto:size>478571</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1286649292000</gphoto:timestamp><gphoto:imageVersion>1266</gphoto:imageVersion><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><gphoto:license id='0' name='Todos os direitos reservados' url=''>ALL_RIGHTS_RESERVED</gphoto:license><exif:tags><exif:imageUniqueID>6399838eaf33d21d08f4ce94187b653e</exif:imageUniqueID></exif:tags><media:group><media:content url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg' height='1181' width='1181' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>Summary</media:description><media:keywords/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s72/photo.jpg' height='72' width='72'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s144/photo.jpg' height='144' width='144'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s288/photo.jpg' height='288' width='288'/><media:title type='plain'>photo.jpg</media:title></media:group></entry>"
|
63
|
+
|
64
|
+
Picasa::HTTP::Photo.stub!(:post_photo).and_return(resp_arr)
|
65
|
+
end
|
66
|
+
|
67
|
+
def mock_get_photo
|
68
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
69
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258</id><published>2010-10-09T18:34:52.000Z</published><updated>2010-10-09T18:34:52.144Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'/><title type='text'>photo.jpg</title><summary type='text'>Summary</summary><content type='image/jpeg' src='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle#5526116634788894258'/><link rel='http://schemas.google.com/photos/2007#canonical' type='text/html' href='http://picasaweb.google.com/lh/photo/RQzOtdWIzuC4uSDK8LaGqg'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='edit-media' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='media-edit' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='http://picasaweb.google.com/lh/reportAbuse?uname=bandmanagertest&aid=5526116602627358369&iid=5526116634788894258'/><gphoto:id>5526116634788894258</gphoto:id><gphoto:version>1</gphoto:version><gphoto:albumid>5526116602627358369</gphoto:albumid><gphoto:access>public</gphoto:access><gphoto:width>1181</gphoto:width><gphoto:height>1181</gphoto:height><gphoto:size>478571</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1286649292000</gphoto:timestamp><gphoto:imageVersion>1266</gphoto:imageVersion><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><gphoto:license id='0' name='Todos os direitos reservados' url=''>ALL_RIGHTS_RESERVED</gphoto:license><exif:tags><exif:imageUniqueID>6399838eaf33d21d08f4ce94187b653e</exif:imageUniqueID></exif:tags><media:group><media:content url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg' height='1181' width='1181' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>Summary</media:description><media:keywords/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s72/photo.jpg' height='72' width='72'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s144/photo.jpg' height='144' width='144'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s288/photo.jpg' height='288' width='288'/><media:title type='plain'>photo.jpg</media:title></media:group></entry>"
|
70
|
+
|
71
|
+
Picasa::HTTP::Photo.stub!(:get_photo).and_return(resp_arr)
|
72
|
+
end
|
73
|
+
|
74
|
+
def mock_get_photos
|
75
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
76
|
+
"<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss'><id>http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526402047218418305</id><updated>2010-10-10T13:02:37.228Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'/><title type='text'>Album Title</title><subtitle type='text'>Album Summary</subtitle><rights type='text'>public</rights><icon>http://lh4.ggpht.com/_Eo7DPaDqPZg/TLG5Yb5yAoE/AAAAAAAABXw/rw9L5Y3wzx4/s160-c/AlbumTitle31.jpg</icon><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526402047218418305'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/AlbumTitle31'/><link rel='http://schemas.google.com/photos/2007#slideshow' type='application/x-shockwave-flash' href='http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fbandmanagertest%2Falbumid%2F5526402047218418305%3Falt%3Drss'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='http://picasaweb.google.com/lh/reportAbuse?uname=bandmanagertest&aid=5526402047218418305'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526402047218418305?start-index=1&max-results=1000'/><author><name>BandManager Test</name><uri>http://picasaweb.google.com/bandmanagertest</uri></author><generator version='1.00' uri='http://picasaweb.google.com/'>Picasaweb</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>1000</openSearch:itemsPerPage><gphoto:id>5526402047218418305</gphoto:id><gphoto:name>AlbumTitle31</gphoto:name><gphoto:location>Album location</gphoto:location><gphoto:access>public</gphoto:access><gphoto:timestamp>1286715744000</gphoto:timestamp><gphoto:numphotos>1</gphoto:numphotos><gphoto:user>bandmanagertest</gphoto:user><gphoto:nickname>BandManager Test</gphoto:nickname><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><georss:where><gml:Point><gml:pos>31.755058 -106.34164</gml:pos></gml:Point></georss:where><gphoto:allowPrints>true</gphoto:allowPrints><gphoto:allowDownloads>true</gphoto:allowDownloads><entry><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526402047218418305/photoid/5526402097573142018</id><published>2010-10-10T13:02:37.000Z</published><updated>2010-10-10T13:02:37.228Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'/><title type='text'>photo.jpg</title><summary type='text'>Photo summary</summary><content type='image/jpeg' src='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLG5bXfSHgI/AAAAAAAABXw/CsjARgrA690/photo.jpg'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526402047218418305/photoid/5526402097573142018'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/AlbumTitle31#5526402097573142018'/><link rel='http://schemas.google.com/photos/2007#canonical' type='text/html' href='http://picasaweb.google.com/lh/photo/rp2tDj2g7taBS5tH05Qe2A'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526402047218418305/photoid/5526402097573142018'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='http://picasaweb.google.com/lh/reportAbuse?uname=bandmanagertest&aid=5526402047218418305&iid=5526402097573142018'/><gphoto:id>5526402097573142018</gphoto:id><gphoto:version>1</gphoto:version><gphoto:position>1.0</gphoto:position><gphoto:albumid>5526402047218418305</gphoto:albumid><gphoto:access>public</gphoto:access><gphoto:width>1181</gphoto:width><gphoto:height>1181</gphoto:height><gphoto:size>478571</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1286715757000</gphoto:timestamp><gphoto:imageVersion>1404</gphoto:imageVersion><gphoto:commentCount>0</gphoto:commentCount><gphoto:license id='0' name='All Rights Reserved' url=''>ALL_RIGHTS_RESERVED</gphoto:license><exif:tags><exif:imageUniqueID>6399838eaf33d21d08f4ce94187b653e</exif:imageUniqueID></exif:tags><media:group><media:content url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLG5bXfSHgI/AAAAAAAABXw/CsjARgrA690/photo.jpg' height='1181' width='1181' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>Photo summary</media:description><media:keywords/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLG5bXfSHgI/AAAAAAAABXw/CsjARgrA690/s72/photo.jpg' height='72' width='72'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLG5bXfSHgI/AAAAAAAABXw/CsjARgrA690/s144/photo.jpg' height='144' width='144'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLG5bXfSHgI/AAAAAAAABXw/CsjARgrA690/s288/photo.jpg' height='288' width='288'/><media:title type='plain'>photo.jpg</media:title></media:group></entry></feed>"
|
77
|
+
|
78
|
+
Picasa::HTTP::Photo.stub!(:get_photos).and_return(resp_arr)
|
79
|
+
end
|
80
|
+
|
81
|
+
def mock_update_photo
|
82
|
+
resp_arr = build_resp_mock_array "200", "OK",
|
83
|
+
"<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/'><id>http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258</id><published>2010-10-09T18:34:52.000Z</published><updated>2010-10-09T18:34:52.144Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'/><title type='text'>photo.jpg</title><summary type='text'>Photo summary updated</summary><content type='image/jpeg' src='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://picasaweb.google.com/data/feed/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='alternate' type='text/html' href='http://picasaweb.google.com/bandmanagertest/TestingTitle#5526116634788894258'/><link rel='http://schemas.google.com/photos/2007#canonical' type='text/html' href='http://picasaweb.google.com/lh/photo/RQzOtdWIzuC4uSDK8LaGqg'/><link rel='self' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258'/><link rel='edit' type='application/atom+xml' href='http://picasaweb.google.com/data/entry/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='edit-media' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='media-edit' type='image/jpeg' href='http://picasaweb.google.com/data/media/api/user/bandmanagertest/albumid/5526116602627358369/photoid/5526116634788894258/1'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='http://picasaweb.google.com/lh/reportAbuse?uname=bandmanagertest&aid=5526116602627358369&iid=5526116634788894258'/><gphoto:id>5526116634788894258</gphoto:id><gphoto:version>1</gphoto:version><gphoto:albumid>5526116602627358369</gphoto:albumid><gphoto:access>public</gphoto:access><gphoto:width>1181</gphoto:width><gphoto:height>1181</gphoto:height><gphoto:size>478571</gphoto:size><gphoto:client/><gphoto:checksum/><gphoto:timestamp>1286649292000</gphoto:timestamp><gphoto:imageVersion>1266</gphoto:imageVersion><gphoto:commentingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><gphoto:license id='0' name='Todos os direitos reservados' url=''>ALL_RIGHTS_RESERVED</gphoto:license><exif:tags><exif:imageUniqueID>6399838eaf33d21d08f4ce94187b653e</exif:imageUniqueID></exif:tags><media:group><media:content url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/photo.jpg' height='1181' width='1181' type='image/jpeg' medium='image'/><media:credit>BandManager Test</media:credit><media:description type='plain'>Summary</media:description><media:keywords/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s72/photo.jpg' height='72' width='72'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s144/photo.jpg' height='144' width='144'/><media:thumbnail url='http://lh5.ggpht.com/_Eo7DPaDqPZg/TLC1zPv4FjI/AAAAAAAABPI/pHeMtRZlR38/s288/photo.jpg' height='288' width='288'/><media:title type='plain'>photo.jpg</media:title></media:group></entry>"
|
84
|
+
|
85
|
+
Picasa::HTTP::Photo.stub!(:update_photo).and_return(resp_arr)
|
86
|
+
end
|
87
|
+
|
88
|
+
def mock_delete_photo
|
89
|
+
resp_arr = build_resp_mock_array "200", "OK", ""
|
90
|
+
Picasa::HTTP::Photo.stub!(:delete_photo).and_return(resp_arr)
|
91
|
+
end
|
92
|
+
|
93
|
+
def mock_post_photo_failure
|
94
|
+
resp_arr = build_resp_mock_array "404", "NotFound", ""
|
95
|
+
Picasa::HTTP::Photo.stub!(:post_photo).and_return(resp_arr)
|
96
|
+
end
|
97
|
+
|
98
|
+
def mock_download_image
|
99
|
+
file = File.open File.dirname(__FILE__)+"/fixture/photo.jpg"
|
100
|
+
Picasa::HTTP::Photo.stub!(:download_image).and_return(file)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def build_resp_mock_array code, message, data, success = true
|
106
|
+
resp_mock = mock()
|
107
|
+
resp_mock.stub!(:code).and_return(code)
|
108
|
+
resp_mock.stub!(:message).and_return(message)
|
109
|
+
resp_mock.stub!(:success?).and_return(success)
|
110
|
+
|
111
|
+
resp_arr = [resp_mock, data]
|
112
|
+
end
|
113
|
+
end
|
data/spec/photo_spec.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Picasa::Photo" do
|
4
|
+
|
5
|
+
it "should save a new photo in a album" do
|
6
|
+
mock_authentication
|
7
|
+
mock_post_album
|
8
|
+
mock_get_album
|
9
|
+
mock_post_photo
|
10
|
+
mock_update_photo
|
11
|
+
|
12
|
+
album = create_album
|
13
|
+
file = File.open 'spec/fixture/photo.jpg'
|
14
|
+
|
15
|
+
photo = PhotoObject.new
|
16
|
+
photo.album = album
|
17
|
+
photo.summary = "Photo summary"
|
18
|
+
photo.file = file
|
19
|
+
|
20
|
+
photo.picasa_save!
|
21
|
+
photo.picasa_save.should be_true
|
22
|
+
|
23
|
+
photo.instance_variables.each do |var_name|
|
24
|
+
value = photo.instance_variable_get var_name
|
25
|
+
value.should_not be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should update a photo" do
|
30
|
+
mock_authentication
|
31
|
+
mock_post_album
|
32
|
+
mock_get_album
|
33
|
+
mock_post_photo
|
34
|
+
mock_update_photo
|
35
|
+
|
36
|
+
photo = create_photo
|
37
|
+
|
38
|
+
photo.summary = "Photo summary updated"
|
39
|
+
photo.picasa_update!
|
40
|
+
photo.summary.should == "Photo summary updated"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should destroy a photo" do
|
44
|
+
mock_authentication
|
45
|
+
mock_post_album
|
46
|
+
mock_get_album
|
47
|
+
mock_post_photo
|
48
|
+
mock_delete_photo
|
49
|
+
|
50
|
+
photo = create_photo
|
51
|
+
photo.destroy!
|
52
|
+
|
53
|
+
photo = create_photo
|
54
|
+
photo.destroy.should be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should raise exception if can not post photo" do
|
58
|
+
mock_authentication
|
59
|
+
mock_post_album
|
60
|
+
mock_get_album
|
61
|
+
mock_get_albums
|
62
|
+
mock_post_photo_failure
|
63
|
+
|
64
|
+
album = create_album
|
65
|
+
|
66
|
+
photo = PhotoObject.new
|
67
|
+
photo.album = album
|
68
|
+
photo.summary = "Photo summary"
|
69
|
+
photo.file = nil
|
70
|
+
|
71
|
+
lambda { photo.picasa_save! }.should raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should find all photos from an album" do
|
75
|
+
mock_authentication
|
76
|
+
mock_post_album
|
77
|
+
mock_post_photo
|
78
|
+
mock_get_album
|
79
|
+
mock_get_photos
|
80
|
+
|
81
|
+
photo = create_photo
|
82
|
+
|
83
|
+
photos = PhotoObject.picasa_find_all photo.album.user.picasa_id,
|
84
|
+
photo.album.picasa_id, photo.album.user.auth_token
|
85
|
+
|
86
|
+
photos.should_not be_nil
|
87
|
+
photos.each do |p|
|
88
|
+
p.album.picasa_id.should == photo.album.picasa_id
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should find a photo" do
|
93
|
+
mock_authentication
|
94
|
+
mock_post_album
|
95
|
+
mock_post_photo
|
96
|
+
mock_get_album
|
97
|
+
mock_get_photo
|
98
|
+
mock_download_image
|
99
|
+
|
100
|
+
photo1 = create_photo
|
101
|
+
user_id = photo1.album.user.picasa_id
|
102
|
+
album_id = photo1.album.picasa_id
|
103
|
+
photo_id = photo1.picasa_id
|
104
|
+
auth_token = photo1.album.user.auth_token
|
105
|
+
|
106
|
+
photo2 = PhotoObject.picasa_find user_id, album_id, photo_id, auth_token
|
107
|
+
|
108
|
+
photo2.picasa_id.should == photo1.picasa_id
|
109
|
+
photo2.album.should_not be_nil
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should retrieve the file when retrieving the photo" do
|
113
|
+
mock_authentication
|
114
|
+
mock_post_album
|
115
|
+
mock_post_photo
|
116
|
+
mock_get_album
|
117
|
+
mock_get_photo
|
118
|
+
mock_update_photo
|
119
|
+
mock_download_image
|
120
|
+
|
121
|
+
photo1 = create_photo
|
122
|
+
album = photo1.album
|
123
|
+
photo2 = album.find_photo photo1.picasa_id
|
124
|
+
photo2.file.should_not be_nil
|
125
|
+
photo2.file.path
|
126
|
+
File.exists?(photo2.file.path).should be_true
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should have the album class" do
|
130
|
+
PhotoObject.album_class
|
131
|
+
photo = PhotoObject.new
|
132
|
+
photo.album_class
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should only uptade photo if it already exists when calling save method" do
|
136
|
+
mock_authentication
|
137
|
+
mock_post_album
|
138
|
+
mock_post_photo
|
139
|
+
mock_get_album
|
140
|
+
mock_get_photo
|
141
|
+
mock_get_photos
|
142
|
+
mock_update_photo
|
143
|
+
mock_download_image
|
144
|
+
|
145
|
+
album = create_album
|
146
|
+
file = File.open 'spec/fixture/photo.jpg'
|
147
|
+
|
148
|
+
photo = PhotoObject.new
|
149
|
+
photo.album = album
|
150
|
+
photo.summary = "Photo summary"
|
151
|
+
photo.file = file
|
152
|
+
|
153
|
+
photo.picasa_save.should be_true
|
154
|
+
|
155
|
+
album = photo.album
|
156
|
+
num_photos = album.photos.size
|
157
|
+
|
158
|
+
photo2 = album.find_photo photo.picasa_id
|
159
|
+
photo2.summary = 'changing summary'
|
160
|
+
photo2.picasa_save.should be_true
|
161
|
+
|
162
|
+
album.photos(true).size.should == num_photos.should
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should only uptade photo if it already exists when calling save method" do
|
166
|
+
mock_authentication
|
167
|
+
mock_post_album
|
168
|
+
mock_post_photo
|
169
|
+
mock_get_album
|
170
|
+
mock_get_photo
|
171
|
+
mock_get_photos
|
172
|
+
mock_update_photo
|
173
|
+
mock_delete_photo
|
174
|
+
mock_download_image
|
175
|
+
|
176
|
+
photo = create_photo
|
177
|
+
|
178
|
+
photo.save
|
179
|
+
photo.save!
|
180
|
+
photo.update
|
181
|
+
photo.update!
|
182
|
+
photo.update_attributes
|
183
|
+
photo.update_attributes!
|
184
|
+
photo.destroy
|
185
|
+
photo.destroy!
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'lib/go_picasa_go'
|
2
|
+
require 'http_response_helper'
|
3
|
+
require 'mock_helper'
|
4
|
+
|
5
|
+
include Picasa::Util
|
6
|
+
include MockHelper
|
7
|
+
|
8
|
+
class UserObject
|
9
|
+
acts_as_picasa_user
|
10
|
+
has_many_picasa_albums :class_name => "AlbumObject"
|
11
|
+
|
12
|
+
def picasa_id
|
13
|
+
"bandmanagertest"
|
14
|
+
end
|
15
|
+
|
16
|
+
def auth_token
|
17
|
+
"DQAAAHsAAAAdMyvdNfPg_iTFD-T_u6bBb-9BegOP7CGWnjah7FCJvnu8aiOoHXJMAJ-6HS_8vOE"+
|
18
|
+
"2zFLXaSzp3oe4mB9lJexTpxxM-CmChSTs-9OBd6nAwNji5yWnLUFv_Q7-ibXMx7820aFdnU7mr6"+
|
19
|
+
"qqvHUhXESdhBEnD1QP_o8dqsP-6T-oig"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class AlbumObject
|
24
|
+
acts_as_picasa_album
|
25
|
+
belongs_to_picasa_user :class_name => "UserObject"
|
26
|
+
has_many_picasa_photos :class_name => 'PhotoObject'
|
27
|
+
end
|
28
|
+
|
29
|
+
class PhotoObject
|
30
|
+
acts_as_picasa_photo
|
31
|
+
belongs_to_picasa_album :class_name => 'AlbumObject'
|
32
|
+
end
|
33
|
+
|
34
|
+
def login(email = 'bandmanagertest@gmail.com', password = '$bandmanager$')
|
35
|
+
resp, body = Picasa::HTTP::Authentication.authenticate(email, password)
|
36
|
+
resp.code.should == "200"
|
37
|
+
resp.message.should == "OK"
|
38
|
+
|
39
|
+
auth_token = extract_auth_token body
|
40
|
+
auth_token.should_not be_nil
|
41
|
+
auth_token.should_not be_empty
|
42
|
+
|
43
|
+
auth_token
|
44
|
+
end
|
45
|
+
|
46
|
+
def post_album opts = {}
|
47
|
+
params = {
|
48
|
+
:title => 'testing title',
|
49
|
+
:summary => 'testing summary',
|
50
|
+
:location => 'testing location',
|
51
|
+
:keywords => 'testing keywords'
|
52
|
+
}
|
53
|
+
|
54
|
+
auth_token = login
|
55
|
+
resp, body = Picasa::HTTP::Album.post_album 'bandmanagertest', auth_token, params.merge(opts)
|
56
|
+
resp.success?.should be_true
|
57
|
+
resp.message.should == "Created"
|
58
|
+
|
59
|
+
body.should_not be_nil
|
60
|
+
body.should_not be_empty
|
61
|
+
|
62
|
+
doc = Nokogiri::XML body
|
63
|
+
doc.at_xpath('//gphoto:id').content
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete_album album_id
|
67
|
+
auth_token = login
|
68
|
+
resp, body = Picasa::HTTP::Album.delete_album "bandmanagertest", album_id, auth_token
|
69
|
+
resp.success?.should be_true
|
70
|
+
resp.message_OK?.should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
def albums_ids
|
74
|
+
auth_token = login
|
75
|
+
resp, body = Picasa::HTTP::Album.get_albums('bandmanagertest', auth_token)
|
76
|
+
|
77
|
+
resp.should_not be_nil
|
78
|
+
body.should_not be_nil
|
79
|
+
|
80
|
+
resp.success?.should be_true
|
81
|
+
resp.message.should == "OK"
|
82
|
+
|
83
|
+
body.should_not be_empty
|
84
|
+
|
85
|
+
doc = Nokogiri.XML body
|
86
|
+
ids = []
|
87
|
+
doc.css('entry').each do |entry|
|
88
|
+
ids << entry.at_css('id').content.split("albumid/")[1].to_i
|
89
|
+
ids.uniq!
|
90
|
+
end
|
91
|
+
|
92
|
+
ids
|
93
|
+
end
|
94
|
+
|
95
|
+
def delete_all_albums
|
96
|
+
ids = albums_ids
|
97
|
+
if ids and ids.size > 0
|
98
|
+
ids.each do |id|
|
99
|
+
delete_album id
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_album
|
105
|
+
user = UserObject.new
|
106
|
+
user.picasa_id = "bandmanagertest"
|
107
|
+
|
108
|
+
album = AlbumObject.new
|
109
|
+
album.user = user
|
110
|
+
album.title = "Album Title"
|
111
|
+
album.summary = "Album Summary"
|
112
|
+
album.location = "Album location"
|
113
|
+
album.keywords = "Album keywords"
|
114
|
+
album.access = "public"
|
115
|
+
|
116
|
+
album.picasa_save!
|
117
|
+
album
|
118
|
+
end
|
119
|
+
|
120
|
+
def post_photo
|
121
|
+
album_id = post_album
|
122
|
+
auth_token = login
|
123
|
+
|
124
|
+
file = File.open 'spec/fixture/photo.jpg'
|
125
|
+
|
126
|
+
resp, data = Picasa::HTTP::Photo.post_photo(
|
127
|
+
'bandmanagertest', album_id, auth_token, "Summary", file
|
128
|
+
)
|
129
|
+
|
130
|
+
resp.code.should == "201"
|
131
|
+
resp.message.should == "Created"
|
132
|
+
data.should_not be_nil
|
133
|
+
data.should_not be_empty
|
134
|
+
|
135
|
+
doc = Nokogiri::XML data
|
136
|
+
photo_id = doc.at_xpath('//gphoto:id').content
|
137
|
+
[album_id, photo_id, auth_token]
|
138
|
+
end
|
139
|
+
|
140
|
+
def create_photo
|
141
|
+
album = create_album
|
142
|
+
file = File.open 'spec/fixture/photo.jpg'
|
143
|
+
|
144
|
+
photo = PhotoObject.new
|
145
|
+
photo.album = album
|
146
|
+
photo.summary = "Photo summary"
|
147
|
+
photo.file = file
|
148
|
+
|
149
|
+
photo.picasa_save.should be_true
|
150
|
+
photo
|
151
|
+
end
|