summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-07 10:22:47 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-07 10:22:47 +0200
commit1a63a36a1734f235539e71284bb4806aaeca6abf (patch)
treed67be562249ba4470f91b756f4dc2b66656cecff
parentadd moose (diff)
downloadnet-backtype-1a63a36a1734f235539e71284bb4806aaeca6abf.tar.gz
update tests
-rw-r--r--t/00_compile.t4
-rw-r--r--t/01_basic.t45
2 files changed, 34 insertions, 15 deletions
diff --git a/t/00_compile.t b/t/00_compile.t
index 6912701..f6505b6 100644
--- a/t/00_compile.t
+++ b/t/00_compile.t
@@ -1,4 +1,4 @@
 use strict;
-use Test::More tests => 1;
+use Test::More tests => 2;
 
-BEGIN { use_ok 'Net::Backtype' }
+BEGIN { use_ok 'Net::Backtype'; use_ok 'Net::Backtweet'; }
diff --git a/t/01_basic.t b/t/01_basic.t
index 2b6fda2..f281c26 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -1,24 +1,43 @@
 use strict;
 use warnings;
 use Test::More;
+
+use HTTP::Response;
 use Net::Backtype;
 use Net::Backtweet;
 
-BEGIN {
-    plan skip_all => 'set $ENV{BACKTYPE_KEY} for this test'
-        unless $ENV{BACKTYPE_KEY};
-}
-
-my $obj = Net::Backtweet->new;
-ok $obj, '... object created';
-my $method = $obj->meta->find_method_by_name('user_comments');
-ok $method->meta->has_attribute('method'), '... got method as attribute';
-is $method->method, 'GET', '... method is GET';
+ok my $backtype = Net::Backtype->new, 'object backtype created';
+_add_handler($backtype);
 
-my $res = $obj->backtweet_search(
-    key => $ENV{BACKTYPE_KEY},
+ok my $res = $backtype->comments_search(
+    key => 's3kr3tk3y',
     q   => 'http://lumberjaph.net'
+  ),
+  'got result for backtype query';
+
+ok my $backtweet = Net::Backtweet->new, 'object backtweet created';
+_add_handler($backtweet);
+
+ok $res = $backtweet->stats_by_url(
+    key => 's3kr3tk3y',
+    q   => 'http://lumberjaph.net',
+  ),
+  'got result for backtweet query';
+
+sub _add_handler {
+    my $object = shift;
+$object->api_useragent->add_handler(
+    'request_send' => sub {
+        my $request  = shift;
+        my $response = HTTP::Response->new(200);
+        $response->header('Content-Type' => 'application/json');
+        $response->content(
+            '{"startindex" : 1, "itemsperpage" : 25, "since_ts" : 1275874078, "totalresults" : "500"}'
+        );
+        $response;
+    }
 );
 
-cmp_ok scalar @{ $res->{tweets} }, '>=', 1, '... got more than one result';
+}
+
 done_testing;