[Bps-public-commit] r20012 - in Net-Google-Code/trunk/t: sample

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jun 17 23:02:55 EDT 2009


Author: sunnavy
Date: Wed Jun 17 23:02:55 2009
New Revision: 20012

Added:
   Net-Google-Code/trunk/t/05.issue_search.t
      - copied, changed from r19865, /Net-Google-Code/trunk/t/05.issues_list.t
   Net-Google-Code/trunk/t/sample/05.issue_search.html
      - copied unchanged from r19706, /Net-Google-Code/trunk/t/sample/05.issues_list.html
   Net-Google-Code/trunk/t/sample/05.issue_search.xml
Removed:
   Net-Google-Code/trunk/t/05.issues_list.t
   Net-Google-Code/trunk/t/sample/05.issues_list.html

Log:
add tests for search->updated_after

Copied: Net-Google-Code/trunk/t/05.issue_search.t (from r19865, /Net-Google-Code/trunk/t/05.issues_list.t)
==============================================================================
--- /Net-Google-Code/trunk/t/05.issues_list.t	(original)
+++ Net-Google-Code/trunk/t/05.issue_search.t	Wed Jun 17 23:02:55 2009
@@ -1,28 +1,44 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 37;
 use Test::MockModule;
 
 use FindBin qw/$Bin/;
 use File::Slurp;
-my $content = read_file("$Bin/sample/05.issues_list.html");
+my $html_content = read_file("$Bin/sample/05.issue_search.html");
+my $xml_content = read_file("$Bin/sample/05.issue_search.xml");
 
 my $mock = Test::MockModule->new('Net::Google::Code::Issue::Search');
-$mock->mock( 'fetch', sub { $content } );
+$mock->mock(
+    'fetch',
+    sub {
+        my $self = shift;
+        my $url  = shift;
+        if ( $url =~ /feeds/ ) {
+            return $xml_content;
+        }
+        else {
+            return $html_content;
+        }
+
+    }
+);
 my $mock_mech = Test::MockModule->new('WWW::Mechanize');
 $mock_mech->mock( 'title',       sub { 'issues' } );
 $mock_mech->mock( 'submit_form', sub { } );
-$mock_mech->mock( 'content',     sub { $content } );
 $mock_mech->mock( 'is_success',  sub { 1 } );
 $mock_mech->mock( 'response',    sub { HTTP::Response->new } );
 my $mock_response = Test::MockModule->new('HTTP::Response');
 $mock_response->mock( 'is_success', sub { 1 } );
-$mock_response->mock( 'content',    sub { $content } );
+$mock_response->mock( 'content',    sub { $html_content } );
 
 use Net::Google::Code::Issue::Search;
 my $search = Net::Google::Code::Issue::Search->new( project => 'test' );
 isa_ok( $search, 'Net::Google::Code::Issue::Search', '$search' );
+
+# search tests
+can_ok( $search, 'search' );
 $search->search(load_after_search => 0);
 
 is( scalar @{ $search->results }, 8, 'results number in total' );
@@ -44,3 +60,37 @@
 
 is_deeply( $search->results->[-1]->labels,
     [qw/0.05 blabla/], 'last result labels' );
+
+# updated_after tests
+can_ok( $search, 'updated_after' );
+my $mock_issue = Test::MockModule->new('Net::Google::Code::Issue');
+$mock_issue->mock(
+    'load',
+    sub {
+        my $id   = shift->id;
+        ok( 1, "load( $id ) is called" );
+    }
+);
+
+my $dt = DateTime->new( year => 2009, month => 6, day => 1 );
+my $issues = $search->updated_after( $dt );
+my @ids = map { $_->id } @$issues;
+is_deeply( \@ids, [ 22, 13, 14, 10 ], 'updated_after 2009-06-01 got 4 issues' );
+$dt = DateTime->new( year => 2010, month => 1, day => 1 );
+$issues = $search->updated_after( $dt );
+is_deeply( $issues, [ ], 'updated_after 2010-01-01 got 0 issues' );
+
+
+# let updated_after call ->search
+$dt = DateTime->new( year => 2008, month => 1, day => 1 );
+my $updated = DateTime->new( year => 2010, month => 1, day => 1 );
+$mock_issue->mock( 'updated', sub { $updated } );
+$issues = $search->updated_after( $dt );
+
+is( scalar @{ $search->results }, 8, 'downgraded to ->search to find issues' );
+
+$updated = DateTime->new( year => 2005, month => 1, day => 1 );
+$mock_issue->mock( 'updated', sub { $updated } );
+$issues = $search->updated_after( $dt );
+is( scalar @{ $search->results },
+    0, 'downgraded updated_after version also filters by the updated date' );

Added: Net-Google-Code/trunk/t/sample/05.issue_search.xml
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/sample/05.issue_search.xml	Wed Jun 17 23:02:55 2009
@@ -0,0 +1,368 @@
+<?xml version="1.0"?>
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <updated>2009-06-12T05:55:48Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic</id>
+ <title>Issue updates for project net-google-code on Google Code</title>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/list"/>
+ <link rel="self" type="application/atom+xml;type=feed" href="http://code.google.com/feeds/p/net-google-code/issueupdates/basic"/>
+ 
+ 
+ <entry>
+ <updated>2009-06-12T05:55:48Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/22/2</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=22#c2" />
+ <title>Update 2 to issue 22 ("for sd test")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>second comment
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-12T05:55:22Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/22/1</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=22#c1" />
+ <title>Update 1 to issue 22 ("for sd test")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>first comment
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-12T05:55:06Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/22</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=22" />
+ <title>Issue 22 created: "for sd test"</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>this is description
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-04T05:35:33Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/13/4</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=13#c4" />
+ <title>Update 4 to issue 13 ("Enter one-line summary")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>test 2
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-04T05:34:42Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/13/3</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=13#c3" />
+ <title>Update 3 to issue 13 ("Enter one-line summary")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>test 2
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-04T05:34:41Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/13/2</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=13#c2" />
+ <title>Update 2 to issue 13 ("Enter one-line summary")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>test 1
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-04T05:02:17Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/13/1</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=13#c1" />
+ <title>Update 1 to issue 13 ("Enter one-line summary")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>06-04 13:02 CST
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-03T11:32:10Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/12</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c12" />
+ <title>Update 12 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Blockedon: 23 </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-02T00:34:20Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/10/16</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=10#c16" />
+ <title>Update 16 to issue 10 ("not touch labels")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>Issue 14 has been merged into this issue.
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-02T00:34:20Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/11</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c11" />
+ <title>Update 11 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Status: Duplicate<br/>Mergedinto: 10<br/>Blockedon: -10 </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-06-02T00:33:32Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/10</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c10" />
+ <title>Update 10 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Blockedon: 10 </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T03:24:40Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/9</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c9" />
+ <title>Update 9 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Summary: sd1 </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T02:45:04Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/8</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c8" />
+ <title>Update 8 to issue 14 ("sd1 test")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Summary: sd1 test<br/>Labels: -priority-critical -test -bool 3 </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T02:40:29Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/7</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c7" />
+ <title>Update 7 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Labels: -Priority-Medium priority-critical ok test bool </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T02:19:57Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/6</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c6" />
+ <title>Update 6 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+this is comment
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T02:12:57Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/5</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c5" />
+ <title>Update 5 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+bla
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-27T01:03:29Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/4</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c4" />
+ <title>Update 4 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>test attachment
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-26T15:34:05Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/3</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c3" />
+ <title>Update 3 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>heya!
+ </pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-26T15:00:28Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/bulk</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/list" />
+ <title>7 issues changed in net-google-code</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>Updates:
+	Status: Duplicate
+
+Comment by sunnavy:
+(No comment was entered for this change.)
+
+Affected issues:
+  issue 15: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=15
+
+  issue 16: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=16
+
+  issue 17: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=17
+
+  issue 18: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=18
+
+  issue 19: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=19
+
+  issue 20: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=20
+
+  issue 21: test sd push
+    http://code.google.com/p/net-google-code/issues/detail?id=21
+
+
+
+</pre>
+ </content>
+</entry>
+
+ 
+ 
+ 
+ <entry>
+ <updated>2009-05-26T14:59:34Z</updated>
+ <id>http://code.google.com/feeds/p/net-google-code/issueupdates/basic/14/2</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/net-google-code/issues/detail?id=14#c2" />
+ <title>Update 2 to issue 14 ("sd1")</title>
+ <author>
+ <name>sunnavy</name>
+ </author>
+ <content type="html"><pre>
+ 
+ <br/>Summary: sd1 </pre>
+ </content>
+</entry>
+
+ 
+ 
+</feed>



More information about the Bps-public-commit mailing list