Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Test two edge cases causing problems and add a fix (fix for one of th…
Browse files Browse the repository at this point in the history
…em previously committed)
  • Loading branch information
amuino committed Dec 1, 2009
1 parent 8593c75 commit 2ac8e40
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ruby_picasa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions spec/ruby_picasa/types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
@user.albums.length.should == 1
@user.albums.first.should be_an_instance_of(Album)
end

end

describe RecentPhotos do
Expand Down Expand Up @@ -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
Expand Down
85 changes: 85 additions & 0 deletions spec/sample/search-without-category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

<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/all</id>
<updated>2009-07-25T17:20:38.208Z</updated>
<title type="text">Search Results</title>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/all"/>
<link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/all?start-index=1&amp;max-results=1&amp;kind=photo&amp;thumbsize=48c%2C512&amp;bbox=-3.50335364182473%2C40.5075502262108%2C-3.38509955817527%2C40.5974009737892"/>
<link rel="next" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/all?start-index=2&amp;max-results=1&amp;kind=photo&amp;thumbsize=48c%2C512&amp;bbox=-3.50335364182473%2C40.5075502262108%2C-3.38509955817527%2C40.5974009737892"/>
<generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator>
<openSearch:totalResults>218</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>1</openSearch:itemsPerPage>
<gphoto:crowded_length>10</gphoto:crowded_length>
<entry>
<id>http://picasaweb.google.com/data/entry/api/user/ferlomu/albumid/5219550776108265377/photoid/5362448251628468514</id>
<published>2009-07-25T17:17:57.000Z</published>
<updated>2009-07-25T17:20:38.208Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/>
<title type="text">Ajedrez albert'09-1.JPG</title>
<summary type="text">Ajedrez albert'09-1</summary>
<content type="image/jpeg" src="http://lh3.ggpht.com/_YuawmZeCmg4/Sms-Rfy6uSI/AAAAAAAAXLs/Lix6u4V4KzI/Ajedrez%20albert%2709-1.JPG"/>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/ferlomu/albumid/5219550776108265377/photoid/5362448251628468514"/>
<link rel="alternate" type="text/html" href="http://picasaweb.google.com/ferlomu/AlgeteMadrid#5362448251628468514"/>
<link rel="http://schemas.google.com/photos/2007#canonical" type="text/html" href="http://picasaweb.google.com/lh/photo/e_vQGcMK47S79mEZqm7qyQ"/>
<link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/ferlomu/albumid/5219550776108265377/photoid/5362448251628468514"/>
<link rel="http://schemas.google.com/photos/2007#report" type="text/html" href="http://picasaweb.google.com/lh/reportAbuse?uname=ferlomu&amp;aid=5219550776108265377&amp;iid=5362448251628468514"/>
<author type="owner">
<name>Fernando ferlomu</name>
<uri>http://picasaweb.google.com/ferlomu</uri>
<email>ferlomu</email>
<gphoto:nickname>Fernando ferlomu</gphoto:nickname>
<gphoto:thumbnail>http://lh4.ggpht.com/_YuawmZeCmg4/AAAAOavZL6c/AAAAAAAAAAA/VV58qG-V7Sk/s32-c/ferlomu.jpg</gphoto:thumbnail>
<gphoto:user>ferlomu</gphoto:user>
</author>
<gphoto:id>5362448251628468514</gphoto:id>
<gphoto:version>3</gphoto:version>
<gphoto:position>41.96</gphoto:position>
<gphoto:albumid>5219550776108265377</gphoto:albumid>
<gphoto:access>public</gphoto:access>
<gphoto:width>1024</gphoto:width>
<gphoto:height>768</gphoto:height>
<gphoto:size>134015</gphoto:size>
<gphoto:client>picasa</gphoto:client>
<gphoto:checksum>80d6b544</gphoto:checksum>
<gphoto:timestamp>1244296116000</gphoto:timestamp>
<gphoto:imageVersion>23739</gphoto:imageVersion>
<gphoto:commentCount>1</gphoto:commentCount>
<exif:tags>
<exif:fstop>3.2</exif:fstop>
<exif:make>FUJIFILM</exif:make>
<exif:model>FinePix S8000fd</exif:model>
<exif:exposure>0.14285715</exif:exposure>
<exif:flash>false</exif:flash>
<exif:focallength>6.4</exif:focallength>
<exif:iso>800</exif:iso>
<exif:time>1244296116000</exif:time>
<exif:imageUniqueID>2CE2725A924C53B91CDE83C94468062D</exif:imageUniqueID>
</exif:tags>
<media:group>
<media:content url="http://lh3.ggpht.com/_YuawmZeCmg4/Sms-Rfy6uSI/AAAAAAAAXLs/Lix6u4V4KzI/Ajedrez%20albert%2709-1.JPG" height="768" width="1024" type="image/jpeg" medium="image"/>
<media:credit>Fernando ferlomu</media:credit>
<media:description type="plain">Ajedrez albert'09-1</media:description>
<media:keywords>ajedrez, algete, ferlomu</media:keywords>
<media:thumbnail url="http://lh3.ggpht.com/_YuawmZeCmg4/Sms-Rfy6uSI/AAAAAAAAXLs/Lix6u4V4KzI/s48-c/Ajedrez%20albert%2709-1.JPG" height="48" width="48"/>
<media:thumbnail url="http://lh3.ggpht.com/_YuawmZeCmg4/Sms-Rfy6uSI/AAAAAAAAXLs/Lix6u4V4KzI/s512/Ajedrez%20albert%2709-1.JPG" height="384" width="512"/>
<media:title type="plain">Ajedrez albert'09-1.JPG</media:title>
</media:group>
<georss:where>
<gml:Envelope>
<gml:lowerCorner>40.5730265 -3.5481977</gml:lowerCorner>
<gml:upperCorner>40.6199504 -3.4629678</gml:upperCorner>
</gml:Envelope>
<gml:Point>
<gml:pos>40.5964885 -3.5055828</gml:pos>
</gml:Point>
</georss:where>
<gphoto:albumtitle>Algete (Madrid)</gphoto:albumtitle>
<gphoto:albumctitle>AlgeteMadrid</gphoto:albumctitle>
<gphoto:albumdesc>Ciudad donde vivo</gphoto:albumdesc>
<gphoto:location>algete</gphoto:location>
<gphoto:snippet/>
<gphoto:snippettype>PHOTO_DESCRIPTION</gphoto:snippettype>
<gphoto:truncated>0</gphoto:truncated>
</entry>
</feed>
27 changes: 27 additions & 0 deletions spec/sample/user-without-photos.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">
<id>http://picasaweb.google.com/data/feed/api/user/default</id>
<updated>2009-12-01T16:37:08.690Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/>
<title type="text">amuino</title>
<subtitle type="text"/>
<icon>http://lh3.ggpht.com/_dBGKLzPvuFk/AAAA2GQW5jY/AAAAAAAAAAA/oxqJbR6Jpww/s64-c/amuino.jpg</icon>
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/amuino?authkey=FPkIHarb4J0"/>
<link rel="alternate" type="text/html" href="http://picasaweb.google.com/amuino"/>
<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&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Famuino%3Fauthkey%3DFPkIHarb4J0%26alt%3Drss"/>
<link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/amuino?q=&amp;start-index=1&amp;max-results=1&amp;kind=photo&amp;thumbsize=48c%2C512&amp;access=private"/>
<author>
<name>amuino</name>
<uri>http://picasaweb.google.com/amuino</uri>
</author>
<generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator>
<openSearch:totalResults>0</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>1</openSearch:itemsPerPage>
<gphoto:user>amuino</gphoto:user>
<gphoto:nickname>amuino</gphoto:nickname>
<gphoto:thumbnail>http://lh3.ggpht.com/_dBGKLzPvuFk/AAAA2GQW5jY/AAAAAAAAAAA/oxqJbR6Jpww/s64-c/amuino.jpg</gphoto:thumbnail>
<gphoto:quotalimit>1073741824</gphoto:quotalimit>
<gphoto:quotacurrent>3320520</gphoto:quotacurrent>
<gphoto:maxPhotosPerAlbum>500</gphoto:maxPhotosPerAlbum>
</feed>

0 comments on commit 2ac8e40

Please sign in to comment.