diff --git a/lib/ruby_picasa.rb b/lib/ruby_picasa.rb index eb4ea85..f996380 100644 --- a/lib/ruby_picasa.rb +++ b/lib/ruby_picasa.rb @@ -351,6 +351,8 @@ def class_from_xml(xml) RubyPicasa::User.new(xml, self) when /#photo$/ RubyPicasa::RecentPhotos.new(xml, self) + when nil + RubyPicasa::Search.new(xml, self) end when /#album$/ case entry_scheme diff --git a/spec/ruby_picasa/types_spec.rb b/spec/ruby_picasa/types_spec.rb index 3679bf6..0864017 100644 --- a/spec/ruby_picasa/types_spec.rb +++ b/spec/ruby_picasa/types_spec.rb @@ -77,6 +77,7 @@ @user.albums.length.should == 1 @user.albums.first.should be_an_instance_of(Album) end + end describe RecentPhotos do @@ -293,6 +294,20 @@ end end +describe "Class from XML" do + it 'should parse result without category cointaining photos' do + @search = @object = Picasa.new(nil).class_from_xml(open_file('search-without-category.xml')) + @search.should be_an_instance_of(Search) + @search.entries.size == 1 + @search.entries.first.should be_an_instance_of Photo + end + + it 'should parse user photo search without photos' do + @search = @object = Picasa.new(nil).class_from_xml(open_file('user-without-photos.xml')) + @search.entries.should be_empty + end +end + describe "Search by bounding box" do before :all do @xml = open_file('search-geo-1-result.atom').read diff --git a/spec/sample/search-without-category.xml b/spec/sample/search-without-category.xml new file mode 100644 index 0000000..dedd0e8 --- /dev/null +++ b/spec/sample/search-without-category.xml @@ -0,0 +1,85 @@ + + + http://picasaweb.google.com/data/feed/api/all + 2009-07-25T17:20:38.208Z + Search Results + + + + Picasaweb + 218 + 1 + 1 + 10 + + http://picasaweb.google.com/data/entry/api/user/ferlomu/albumid/5219550776108265377/photoid/5362448251628468514 + 2009-07-25T17:17:57.000Z + 2009-07-25T17:20:38.208Z + + Ajedrez albert'09-1.JPG + Ajedrez albert'09-1 + + + + + + + + Fernando ferlomu + http://picasaweb.google.com/ferlomu + ferlomu + Fernando ferlomu + http://lh4.ggpht.com/_YuawmZeCmg4/AAAAOavZL6c/AAAAAAAAAAA/VV58qG-V7Sk/s32-c/ferlomu.jpg + ferlomu + + 5362448251628468514 + 3 + 41.96 + 5219550776108265377 + public + 1024 + 768 + 134015 + picasa + 80d6b544 + 1244296116000 + 23739 + 1 + + 3.2 + FUJIFILM + FinePix S8000fd + 0.14285715 + false + 6.4 + 800 + 1244296116000 + 2CE2725A924C53B91CDE83C94468062D + + + + Fernando ferlomu + Ajedrez albert'09-1 + ajedrez, algete, ferlomu + + + Ajedrez albert'09-1.JPG + + + + 40.5730265 -3.5481977 + 40.6199504 -3.4629678 + + + 40.5964885 -3.5055828 + + + Algete (Madrid) + AlgeteMadrid + Ciudad donde vivo + algete + + PHOTO_DESCRIPTION + 0 + + \ No newline at end of file diff --git a/spec/sample/user-without-photos.xml b/spec/sample/user-without-photos.xml new file mode 100644 index 0000000..2cf64ab --- /dev/null +++ b/spec/sample/user-without-photos.xml @@ -0,0 +1,27 @@ + + + http://picasaweb.google.com/data/feed/api/user/default + 2009-12-01T16:37:08.690Z + + amuino + + http://lh3.ggpht.com/_dBGKLzPvuFk/AAAA2GQW5jY/AAAAAAAAAAA/oxqJbR6Jpww/s64-c/amuino.jpg + + + + + + amuino + http://picasaweb.google.com/amuino + + Picasaweb + 0 + 1 + 1 + amuino + amuino + http://lh3.ggpht.com/_dBGKLzPvuFk/AAAA2GQW5jY/AAAAAAAAAAA/oxqJbR6Jpww/s64-c/amuino.jpg + 1073741824 + 3320520 + 500 + \ No newline at end of file