picasa 0.3.3 → 0.4.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.
- data/.gitignore +1 -0
- data/.travis.yml +6 -1
- data/Gemfile +6 -0
- data/README.md +16 -24
- data/Rakefile +1 -1
- data/lib/picasa.rb +18 -12
- data/lib/picasa/api/album.rb +45 -0
- data/lib/picasa/client.rb +14 -0
- data/lib/picasa/connection.rb +86 -0
- data/lib/picasa/exceptions.rb +17 -0
- data/lib/picasa/presenter/album.rb +76 -0
- data/lib/picasa/presenter/album_list.rb +60 -0
- data/lib/picasa/presenter/author.rb +15 -0
- data/lib/picasa/presenter/base.rb +29 -0
- data/lib/picasa/presenter/link.rb +19 -0
- data/lib/picasa/presenter/media.rb +27 -0
- data/lib/picasa/presenter/photo.rb +79 -0
- data/lib/picasa/presenter/thumbnail.rb +19 -0
- data/lib/picasa/utils.rb +44 -0
- data/lib/picasa/version.rb +1 -1
- data/picasa.gemspec +4 -15
- data/test/api/album_test.rb +24 -0
- data/test/client_test.rb +14 -0
- data/test/connection_test.rb +71 -0
- data/test/fixtures/album/album-list-with-tag.txt +105 -0
- data/test/fixtures/album/album-list.txt +105 -0
- data/test/fixtures/album/album-show-with-max-results.txt +131 -0
- data/test/fixtures/album/album-show-with-tag-and-many-photos.txt +156 -0
- data/test/fixtures/album/album-show-with-tag-and-one-photo.txt +105 -0
- data/test/fixtures/album/album-show.txt +169 -0
- data/test/fixtures/auth/failure.txt +12 -0
- data/test/fixtures/auth/success.txt +14 -0
- data/test/fixtures/json.txt +435 -0
- data/test/fixtures/photo/photo-list-all-with-q.txt +556 -0
- data/test/fixtures/photo/photo-list-all.txt +623 -0
- data/test/fixtures/photo/photo-list-user.txt +388 -0
- data/test/fixtures/presenters/album_list.xml +88 -0
- data/test/fixtures/presenters/album_show.xml +152 -0
- data/test/fixtures/presenters/album_show_with_one_photo.xml +88 -0
- data/test/fixtures/tag/tag-list-album.txt +77 -0
- data/test/fixtures/tag/tag-list-photo.txt +72 -0
- data/test/fixtures/tag/tag-list.txt +68 -0
- data/test/helper.rb +12 -6
- data/test/presenter/album_list_test.rb +67 -0
- data/test/presenter/album_test.rb +173 -0
- data/test/presenter/author_test.rb +17 -0
- data/test/presenter/base_test.rb +27 -0
- data/test/presenter/link_test.rb +21 -0
- data/test/presenter/media_test.rb +29 -0
- data/test/presenter/photo_test.rb +81 -0
- data/test/presenter/thumbnail_test.rb +24 -0
- data/test/utils_test.rb +84 -0
- metadata +66 -31
- data/lib/picasa/config.rb +0 -15
- data/lib/picasa/web_albums.rb +0 -56
- data/test/fixtures/albums +0 -15
- data/test/fixtures/photos +0 -15
- data/test/test_config.rb +0 -12
- data/test/test_web_albums.rb +0 -44
data/test/helper.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require "minitest/autorun"
|
2
|
-
require "
|
2
|
+
require "webmock/minitest"
|
3
|
+
require "mocha"
|
3
4
|
|
4
5
|
require "picasa"
|
5
6
|
|
7
|
+
xml_parser = ENV["XML_PARSER"] || "libxml"
|
8
|
+
|
9
|
+
require xml_parser if ["nokogiri", "libxml", "ox"].include?(xml_parser)
|
10
|
+
MultiXml.parser = xml_parser
|
11
|
+
|
6
12
|
class MiniTest::Unit::TestCase
|
7
13
|
def setup
|
8
|
-
|
14
|
+
WebMock.disable_net_connect!
|
9
15
|
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
File.read(
|
17
|
+
# Recording response is as simple as writing in terminal:
|
18
|
+
# curl -is -H "GData-Version: 2" "https://picasaweb.google.com/data/feed/api/user/username?prettyprint=true" -X GET > test/fixtures/albums.txt
|
19
|
+
def fixture(filename)
|
20
|
+
File.read(File.join("test", "fixtures", filename))
|
15
21
|
end
|
16
22
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::AlbumList do
|
5
|
+
before do
|
6
|
+
body = MultiXml.parse(fixture("presenters/album_list.xml"))
|
7
|
+
@album_list = Picasa::Presenter::AlbumList.new(body["feed"])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has author name" do
|
11
|
+
assert_equal "Wojciech Wnętrzak", @album_list.author.name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has author uri" do
|
15
|
+
assert_equal "https://picasaweb.google.com/106136347770555028022", @album_list.author.uri
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has links" do
|
19
|
+
assert_equal 4, @album_list.links.size
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has title" do
|
23
|
+
assert_equal "106136347770555028022", @album_list.title
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has updated" do
|
27
|
+
assert_equal "2011-11-19T07:47:33+00:00", @album_list.updated.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has icon" do
|
31
|
+
expected = "https://lh3.googleusercontent.com/-6ezHc54U8x0/AAAAAAAAAAI/AAAAAAAAAAA/PBuxm7Ehn6E/s64-c/106136347770555028022.jpg"
|
32
|
+
assert_equal expected, @album_list.icon
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has generator" do
|
36
|
+
assert_equal "Picasaweb", @album_list.generator
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has total_results" do
|
40
|
+
assert_equal 2, @album_list.total_results
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has start_index" do
|
44
|
+
assert_equal 1, @album_list.start_index
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has items_per_page" do
|
48
|
+
assert_equal 1000, @album_list.items_per_page
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has user" do
|
52
|
+
assert_equal "106136347770555028022", @album_list.user
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has nickname" do
|
56
|
+
assert_equal "Wojciech Wnętrzak", @album_list.nickname
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has thumbnail" do
|
60
|
+
expected = "https://lh3.googleusercontent.com/-6ezHc54U8x0/AAAAAAAAAAI/AAAAAAAAAAA/PBuxm7Ehn6E/s64-c/106136347770555028022.jpg"
|
61
|
+
assert_equal expected, @album_list.thumbnail
|
62
|
+
end
|
63
|
+
|
64
|
+
it "has entries" do
|
65
|
+
assert_equal 2, @album_list.entries.size
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::Album do
|
5
|
+
describe "album from album list" do
|
6
|
+
before do
|
7
|
+
body = MultiXml.parse(fixture("presenters/album_list.xml"))
|
8
|
+
@album = Picasa::Presenter::Album.new(body["feed"]["entry"][0])
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has author name" do
|
12
|
+
assert_equal "Wojciech Wnętrzak", @album.author.name
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has author uri" do
|
16
|
+
assert_equal "https://picasaweb.google.com/106136347770555028022", @album.author.uri
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has links" do
|
20
|
+
assert_equal 3, @album.links.size
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has media credit" do
|
24
|
+
assert_equal "Wojciech Wnętrzak", @album.media.credit
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has media thumbnail url" do
|
28
|
+
assert_equal "https://lh6.googleusercontent.com/-u_2FJXbbliU/SMU_eBetTXE/AAAAAAAAAkU/3XThNVnAM-4/s160-c/Test2.jpg", @album.media.thumbnails[0].url
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has published" do
|
32
|
+
assert_equal "2008-09-08T07:00:00+00:00", @album.published.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has updated" do
|
36
|
+
assert_equal "2011-07-28T18:26:00+00:00", @album.updated.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has title" do
|
40
|
+
assert_equal "test2", @album.title
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has summary" do
|
44
|
+
assert_nil @album.summary
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has rights" do
|
48
|
+
assert_equal "public", @album.rights
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has id" do
|
52
|
+
assert_equal "5243667126168669553", @album.id
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has name" do
|
56
|
+
assert_equal "Test2", @album.name
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has location" do
|
60
|
+
assert_nil @album.location
|
61
|
+
end
|
62
|
+
|
63
|
+
it "has access" do
|
64
|
+
assert_equal "public", @album.access
|
65
|
+
end
|
66
|
+
|
67
|
+
it "has timestamp" do
|
68
|
+
assert_equal "1220857200000", @album.timestamp
|
69
|
+
end
|
70
|
+
|
71
|
+
it "has numphotos" do
|
72
|
+
assert_equal 3, @album.numphotos
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has user" do
|
76
|
+
assert_equal "106136347770555028022", @album.user
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has nickname" do
|
80
|
+
assert_equal "Wojciech Wnętrzak", @album.nickname
|
81
|
+
end
|
82
|
+
|
83
|
+
it "has empty photo entries" do
|
84
|
+
assert_empty @album.entries
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "album from album show" do
|
89
|
+
before do
|
90
|
+
body = MultiXml.parse(fixture("presenters/album_show.xml"))
|
91
|
+
@album = Picasa::Presenter::Album.new(body["feed"])
|
92
|
+
end
|
93
|
+
|
94
|
+
it "has author name" do
|
95
|
+
assert_equal "Wojciech Wnętrzak", @album.author.name
|
96
|
+
end
|
97
|
+
|
98
|
+
it "has author uri" do
|
99
|
+
assert_equal "https://picasaweb.google.com/106136347770555028022", @album.author.uri
|
100
|
+
end
|
101
|
+
|
102
|
+
it "has links" do
|
103
|
+
assert_equal 5, @album.links.size
|
104
|
+
end
|
105
|
+
|
106
|
+
it "has published" do
|
107
|
+
assert_nil @album.published
|
108
|
+
end
|
109
|
+
|
110
|
+
it "has updated" do
|
111
|
+
assert_equal "2011-07-28T18:26:00+00:00", @album.updated.to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
it "has title" do
|
115
|
+
assert_equal "test2", @album.title
|
116
|
+
end
|
117
|
+
|
118
|
+
it "has summary" do
|
119
|
+
assert_nil @album.summary
|
120
|
+
end
|
121
|
+
|
122
|
+
it "has rights" do
|
123
|
+
assert_equal "public", @album.rights
|
124
|
+
end
|
125
|
+
|
126
|
+
it "has id" do
|
127
|
+
assert_equal "5243667126168669553", @album.id
|
128
|
+
end
|
129
|
+
|
130
|
+
it "has name" do
|
131
|
+
assert_equal "Test2", @album.name
|
132
|
+
end
|
133
|
+
|
134
|
+
it "has location" do
|
135
|
+
assert_nil @album.location
|
136
|
+
end
|
137
|
+
|
138
|
+
it "has access" do
|
139
|
+
assert_equal "public", @album.access
|
140
|
+
end
|
141
|
+
|
142
|
+
it "has timestamp" do
|
143
|
+
assert_equal "1220857200000", @album.timestamp
|
144
|
+
end
|
145
|
+
|
146
|
+
it "has numphotos" do
|
147
|
+
assert_equal 3, @album.numphotos
|
148
|
+
end
|
149
|
+
|
150
|
+
it "has user" do
|
151
|
+
assert_equal "106136347770555028022", @album.user
|
152
|
+
end
|
153
|
+
|
154
|
+
it "has nickname" do
|
155
|
+
assert_equal "Wojciech Wnętrzak", @album.nickname
|
156
|
+
end
|
157
|
+
|
158
|
+
it "has photo entries" do
|
159
|
+
assert_equal 3, @album.entries.size
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "album from show with single photo" do
|
164
|
+
before do
|
165
|
+
body = MultiXml.parse(fixture("presenters/album_show_with_one_photo.xml"))
|
166
|
+
@album = Picasa::Presenter::Album.new(body["feed"])
|
167
|
+
end
|
168
|
+
|
169
|
+
it "has single photo entry in array" do
|
170
|
+
assert_kind_of Array, @album.entries
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::Author do
|
5
|
+
before do
|
6
|
+
body = MultiXml.parse(fixture("presenters/album_list.xml"))
|
7
|
+
@author = Picasa::Presenter::Author.new(body["feed"]["author"])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has name" do
|
11
|
+
assert_equal "Wojciech Wnętrzak", @author.name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has uri" do
|
15
|
+
assert_equal "https://picasaweb.google.com/106136347770555028022", @author.uri
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
class TestPresenter < Picasa::Presenter::Base
|
5
|
+
def body
|
6
|
+
parsed_body[:body]
|
7
|
+
end
|
8
|
+
|
9
|
+
def nil_value
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Picasa::Presenter::Base do
|
15
|
+
before do
|
16
|
+
@presenter = TestPresenter.new({:body => "presented body"})
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has parsed_body" do
|
20
|
+
assert_equal @presenter.parsed_body, {:body => "presented body"}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has inspect with class name and defined methods" do
|
24
|
+
expected = %q{#<TestPresenter body: "presented body", nil_value: nil>}
|
25
|
+
assert_equal expected, @presenter.inspect
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::Link do
|
5
|
+
before do
|
6
|
+
body = MultiXml.parse(fixture("presenters/album_list.xml"))
|
7
|
+
@link = Picasa::Presenter::Link.new(body["feed"]["link"][0])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has rel" do
|
11
|
+
assert_equal "http://schemas.google.com/g/2005#feed", @link.rel
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has type" do
|
15
|
+
assert_equal "application/atom+xml", @link.type
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has href" do
|
19
|
+
assert_equal "https://picasaweb.google.com/data/feed/api/user/106136347770555028022", @link.href
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::Media do
|
5
|
+
before do
|
6
|
+
body = MultiXml.parse(fixture("presenters/album_show.xml"))
|
7
|
+
@media = Picasa::Presenter::Media.new(body["feed"]["entry"][0]["group"])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has credit" do
|
11
|
+
assert_equal "Wojciech Wnętrzak", @media.credit
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has description" do
|
15
|
+
assert_nil @media.description
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has keywords" do
|
19
|
+
assert_nil @media.keywords
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has title" do
|
23
|
+
assert_equal "Kashmir range.jpg", @media.title
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has thumbnails" do
|
27
|
+
assert_equal 3, @media.thumbnails.size
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "helper"
|
3
|
+
|
4
|
+
describe Picasa::Presenter::Photo do
|
5
|
+
before do
|
6
|
+
body = MultiXml.parse(fixture("presenters/album_show.xml"))
|
7
|
+
@photo = Picasa::Presenter::Photo.new(body["feed"]["entry"][0])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has links" do
|
11
|
+
assert_equal 5, @photo.links.size
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has media credit" do
|
15
|
+
assert_equal "Wojciech Wnętrzak", @photo.media.credit
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has id" do
|
19
|
+
assert_equal "5243667226703402962", @photo.id
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has published" do
|
23
|
+
assert_equal "2008-09-08T15:06:55+00:00", @photo.published.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has updated" do
|
27
|
+
assert_equal "2009-06-24T15:59:48+00:00", @photo.updated.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has title" do
|
31
|
+
assert_equal "Kashmir range.jpg", @photo.title
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has summary" do
|
35
|
+
assert_nil @photo.summary
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has album_id" do
|
39
|
+
assert_equal "5243667126168669553", @photo.album_id
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has access" do
|
43
|
+
assert_equal "public", @photo.access
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has width" do
|
47
|
+
assert_equal 717, @photo.width
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has height" do
|
51
|
+
assert_equal 468, @photo.height
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has size" do
|
55
|
+
assert_equal 79465, @photo.size
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has checksum" do
|
59
|
+
assert_nil @photo.checksum
|
60
|
+
end
|
61
|
+
|
62
|
+
it "has timestamp" do
|
63
|
+
assert_equal "1220886415000", @photo.timestamp
|
64
|
+
end
|
65
|
+
|
66
|
+
it "has image_version" do
|
67
|
+
assert_equal 91, @photo.image_version
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has commenting_enabled" do
|
71
|
+
assert_equal true, @photo.commenting_enabled
|
72
|
+
end
|
73
|
+
|
74
|
+
it "has comment_count" do
|
75
|
+
assert_equal 0, @photo.comment_count
|
76
|
+
end
|
77
|
+
|
78
|
+
it "has license" do
|
79
|
+
assert_equal "ALL_RIGHTS_RESERVED", @photo.license
|
80
|
+
end
|
81
|
+
end
|