picasawebalbums 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,6 +39,8 @@ Get photos with specific tags
39
39
  repo = PicasaWebAlbums.get_repository('someperson@gmail.com', 'somepassword')
40
40
  photos = repo.get_photos_by_tags(['cat', 'dog'])
41
41
  # returns photos tagged with 'cat' AND 'dog'
42
+
43
+ To test the library with a Picasa Web Albums account, replace the values in /test/config/test_account.yml with the known values from the account.
42
44
 
43
45
  Methods
44
46
  -------
@@ -1,3 +1,3 @@
1
1
  module PicasaWebAlbums
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -43,9 +43,9 @@ module AlbumsRepository
43
43
  return album_to_return
44
44
  end
45
45
 
46
- def create_album(album)
47
- entry = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gphoto='http://schemas.google.com/photos/2007'><title type='text'>#{album.title}</title><summary type='text'>#{album.description}</summary><gphoto:location></gphoto:location><gphoto:access>#{album.access}</gphoto:access><gphoto:timestamp></gphoto:timestamp><media:group><media:keywords></media:keywords></media:group><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'></category></entry>"
48
- post_new_album(entry)
46
+ def create_album(new_album)
47
+ atom = get_album_atom(new_album)
48
+ post_new_album(atom)
49
49
  end
50
50
 
51
51
  def delete_album_by_id(album_id)
@@ -60,8 +60,27 @@ module AlbumsRepository
60
60
  return res.code
61
61
  end
62
62
 
63
+ #def update_album(modified_album)
64
+ # atom = get_album_atom(modified_album)
65
+ # uri = URI(modified_album.edit_url)
66
+ # status = ""
67
+ # Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
68
+ # request = Net::HTTP::Put.new uri.request_uri
69
+ # request['Authorization'] = @authentication_token
70
+ # request['Content-Type'] = "application/atom+xml; charset=UTF-8; type=entry"
71
+ # request.body = atom
72
+ # response = http.request(request)
73
+ # status = response.code
74
+ # end
75
+ # return status
76
+ #end
77
+
63
78
  private
64
79
 
80
+ def get_album_atom(album)
81
+ return "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gphoto='http://schemas.google.com/photos/2007'><title type='text'>#{album.title}</title><summary type='text'>#{album.description}</summary><gphoto:location></gphoto:location><gphoto:access>#{album.access}</gphoto:access><gphoto:timestamp></gphoto:timestamp><media:group><media:keywords></media:keywords></media:group><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'></category></entry>"
82
+ end
83
+
65
84
  def get_edit_url_from_entry(entry)
66
85
  href = ""
67
86
  entry.elements.each("link") do |link|
@@ -0,0 +1,12 @@
1
+ email: apitest33@gmail.com
2
+ password: ruhak23A
3
+ number_of_albums: 3
4
+ album:
5
+ title: Bio Profile Pics
6
+ id: "5689734429356072049"
7
+ slug: BioProfilePics
8
+ number_of_photos: 1
9
+ photo:
10
+ id: "5689734429327880498"
11
+ caption: Testing!!!?
12
+ tag: baloney
@@ -0,0 +1,63 @@
1
+ require 'test/unit'
2
+ require_relative '../../lib/picasawebalbums'
3
+
4
+ module PicasaWebAlbums
5
+ class TestAlbums < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @test_account = YAML::load(File.open(File.expand_path('test/config/test_account.yml')))
9
+ @repo = PicasaWebAlbums.get_repository('apitest33@gmail.com', 'ruhak23A')
10
+ end
11
+
12
+ def test_get_all_albums
13
+ albums = @repo.get_all_albums
14
+ assert_equal @test_account["number_of_albums"], albums.count
15
+ end
16
+
17
+ def test_get_album_by_id
18
+ album = @repo.get_album_by_id(@test_account["album"]["id"])
19
+ assert_equal @test_account["album"]["title"], album.title
20
+ end
21
+
22
+ def test_get_album_by_title
23
+ album = @repo.get_album_by_title(@test_account["album"]["title"])
24
+ assert_equal @test_account["album"]["id"], album.id
25
+ end
26
+
27
+ def test_get_album_by_slug
28
+ album = @repo.get_album_by_slug(@test_account["album"]["slug"])
29
+ assert_equal @test_account["album"]["id"], album.id
30
+ end
31
+
32
+ def test_create_new_album
33
+ album = Album.new
34
+ album.title = "Programmatic album title"
35
+ album.description = "This is my programmatic album description!"
36
+ album.access = "private"
37
+ status_code = @repo.create_album(album)
38
+ assert_equal "201", status_code
39
+ #update_album(album.title)
40
+ delete_album
41
+ end
42
+
43
+ private
44
+
45
+ def update_album(album_title)
46
+ album = @repo.get_album_by_title(album_title)
47
+ new_description = "Some new description"
48
+ album.description = new_description
49
+ @repo.update_album(album)
50
+ album_retrieved = @repo.get_album_by_title("Programmatic album title")
51
+ assert_equal new_description, album_retrieved.description
52
+ end
53
+
54
+ def delete_album
55
+ album = @repo.get_album_by_title("Programmatic album title")
56
+ if (album != nil)
57
+ status_code = @repo.delete_album_by_id(album.id)
58
+ assert_equal "200", status_code
59
+ end
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+ require 'yaml'
3
+ require_relative '../../lib/picasawebalbums'
4
+
5
+ module PicasaWebAlbums
6
+ class TestPhotos < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @test_account = YAML::load(File.open(File.expand_path('test/config/test_account.yml')))
10
+ @repo = PicasaWebAlbums.get_repository(@test_account["email"], @test_account["password"])
11
+ end
12
+
13
+ def test_get_photos_from_album
14
+ album = @repo.get_album_by_id(@test_account["album"]["id"])
15
+ photos = @repo.get_photos_by_album_id(album.id)
16
+ assert_equal photos.count, @test_account["album"]["number_of_photos"]
17
+ end
18
+
19
+ def test_get_photo_by_album_and_id
20
+ album = @repo.get_album_by_slug(@test_account["album"]["slug"])
21
+ photo = @repo.get_photo_by_album_id_and_photo_id(album.id, @test_account["album"]["photo"]["id"])
22
+ assert_equal @test_account["album"]["photo"]["caption"], photo.caption
23
+ end
24
+
25
+ def test_get_photos_by_tags
26
+ tags_array = Array.new(1, @test_account["album"]["photo"]["tag"])
27
+ photos = @repo.get_photos_by_tags(tags_array)
28
+ assert_equal photos.count, @test_account["album"]["number_of_photos"]
29
+ end
30
+
31
+ end
32
+ end
@@ -1,11 +1,12 @@
1
1
  require 'test/unit'
2
2
  require 'shoulda'
3
- require_relative '../lib/picasawebalbums'
3
+ require_relative '../../lib/picasawebalbums'
4
4
 
5
5
  module PicasaWebAlbums
6
6
  class TestTags < Test::Unit::TestCase
7
7
 
8
8
  def setup
9
+ @test_account = YAML::load(File.open(File.expand_path('test/config/test_account.yml')))
9
10
  @repo = PicasaWebAlbums.get_repository('apitest33@gmail.com', 'ruhak23A')
10
11
  end
11
12
 
@@ -0,0 +1,3 @@
1
+ require_relative 'integration/test_albums'
2
+ require_relative 'integration/test_photos'
3
+ require_relative 'integration/test_tags'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picasawebalbums
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-24 00:00:00.000000000 Z
12
+ date: 2011-12-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple way to retrieve albums, photos, tags, etc. from Picasa Web Albums.
15
15
  email:
@@ -32,9 +32,11 @@ files:
32
32
  - lib/repositories/photos_repository.rb
33
33
  - lib/repositories/repository.rb
34
34
  - lib/repositories/tags_repository.rb
35
- - test/test_albums.rb
36
- - test/test_photos.rb
37
- - test/test_tags.rb
35
+ - test/config/test_account.yml
36
+ - test/integration/test_albums.rb
37
+ - test/integration/test_photos.rb
38
+ - test/integration/test_tags.rb
39
+ - test/tests.rb
38
40
  homepage: https://github.com/mkraft/PicasaWebAlbums
39
41
  licenses:
40
42
  - MIT
@@ -61,6 +63,8 @@ signing_key:
61
63
  specification_version: 3
62
64
  summary: Provides programmatic access to Picasa Web Albums data.
63
65
  test_files:
64
- - test/test_albums.rb
65
- - test/test_photos.rb
66
- - test/test_tags.rb
66
+ - test/config/test_account.yml
67
+ - test/integration/test_albums.rb
68
+ - test/integration/test_photos.rb
69
+ - test/integration/test_tags.rb
70
+ - test/tests.rb
@@ -1,50 +0,0 @@
1
- require 'test/unit'
2
- require_relative '../lib/picasawebalbums'
3
-
4
- module PicasaWebAlbums
5
- class TestAlbums < Test::Unit::TestCase
6
-
7
- def setup
8
- @repo = PicasaWebAlbums.get_repository('apitest33@gmail.com', 'ruhak23A')
9
- end
10
-
11
- def test_get_all_albums
12
- albums = @repo.get_all_albums
13
- assert_equal 3, albums.count
14
- end
15
-
16
- def test_get_album_by_id
17
- album = @repo.get_album_by_id("5461230096110151249")
18
- assert_equal "Banner Images", album.title
19
- end
20
-
21
- def test_get_album_by_title
22
- album = @repo.get_album_by_title("Bio Profile Pics")
23
- assert_equal "5689734429356072049", album.id
24
- end
25
-
26
- def test_get_album_by_slug
27
- album = @repo.get_album_by_slug("960x350")
28
- assert_equal "5577380987485671713", album.id
29
- end
30
-
31
- def test_create_new_album
32
- album = Album.new
33
- album.title = "Programmatic album title"
34
- album.description = "This is my programmatic album description!"
35
- album.access = "private"
36
- status_code = @repo.create_album(album)
37
- assert_equal "201", status_code
38
- delete_album
39
- end
40
-
41
- def delete_album
42
- album = @repo.get_album_by_title("Programmatic album title")
43
- if (album != nil)
44
- status_code = @repo.delete_album_by_id(album.id)
45
- assert_equal "200", status_code
46
- end
47
- end
48
-
49
- end
50
- end
@@ -1,29 +0,0 @@
1
- require 'test/unit'
2
- require_relative '../lib/picasawebalbums'
3
-
4
- module PicasaWebAlbums
5
- class TestPhotos < Test::Unit::TestCase
6
-
7
- def setup
8
- @repo = PicasaWebAlbums.get_repository('apitest33@gmail.com', 'ruhak23A')
9
- end
10
-
11
- def test_get_photos_from_album
12
- album = @repo.get_album_by_id(5461230096110151249)
13
- photos = @repo.get_photos_by_album_id(album.id)
14
- assert_equal true, photos.count > 0
15
- end
16
-
17
- def test_get_photo_by_album_and_id
18
- album = @repo.get_album_by_slug("960x350")
19
- photo = @repo.get_photo_by_album_id_and_photo_id(album.id, "5577383323184640194")
20
- assert_equal "Lake Joe Home.", photo.caption
21
- end
22
-
23
- def test_get_photos_by_tags
24
- photos = @repo.get_photos_by_tags(['brick'])
25
- assert photos.count > 0
26
- end
27
-
28
- end
29
- end