summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-12-20 15:52:22 +0100
committerfranck cuny <franck@lumberjaph.net>2009-12-20 15:52:22 +0100
commitabcc81f7501ac86b528aa5cdabcea26a0049cc27 (patch)
tree1d78c0cb23713aefd655489f18bfb060f1b2ad05
parentremove and update some tests (diff)
downloadmoosex-net-api-abcc81f7501ac86b528aa5cdabcea26a0049cc27.tar.gz
remove and update some tests
-rw-r--r--t/01_basic.t43
-rw-r--r--t/02_fail.t13
-rw-r--r--t/03_identica.t24
-rw-r--r--t/04_wow.t16
-rw-r--r--t/10_mx_net_api_test.t43
5 files changed, 25 insertions, 114 deletions
diff --git a/t/01_basic.t b/t/01_basic.t
index 471f3dd..3154298 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -7,29 +7,36 @@ use FakeAPI;
 
 my $obj = FakeAPI->new;
 ok $obj, "... object created";
-ok $obj->meta->has_attribute('useragent'),
+ok $obj->meta->has_attribute('api_useragent'),
     "... useragent attribute have been added";
 
-ok my $method = $obj->meta->find_method_by_name('bar'),
-    '... method bar have been created';
+ok my $method = $obj->meta->find_method_by_name('get_user'),
+    '... method get_user have been created';
 
 ok $method->meta->has_attribute('path'), '... method bar have attribute path';
-
-throws_ok { $obj->baz } qr/bla is declared as required, but is not present/,
-    "... check required params";
-
-throws_ok {
-    $obj->bar( bar => 1, );
-}
-qr/baz is declared as required, but is not present/,
-    "... check required params are present";
-
-throws_ok {
-    $obj->bar( bar => 1, foo => 2, );
-}
-qr/foo is not declared as a param/, "... check declared params";
+is $method->path, '/user/$id', '... get good path value';
 
 ok my @methods = $obj->meta->local_api_methods(), '... get api methods';
-is scalar @methods, 3, '... got 3 methods in our API';
+is scalar @methods, 6, '... get 6 methods in our API';
+
+ok my $users = $obj->users(), "... get users list";
+is $users->[0]->{user}, "bruce wayne", "... get bruce wayne";
+
+ok my $user = $obj->get_user( id => $users->[0]->{id} ),
+    "... fetch bruce wayne informations";
+is $user->{user}, "bruce wayne", "... get bruce wayne";
+
+dies_ok { $obj->get_user( id => 12 ) } "... can't fetch unknown user";
+my $err = $@;
+is $err->http_code, 404, "... get 404";
+
+my $auth_obj = FakeAPI->new();
+use Try::Tiny;
+use YAML::Syck;
+try {
+    my $res = $auth_obj->auth_get_user(id => 1);
+}catch{
+    warn Dump $_;
+};
 
 done_testing;
diff --git a/t/02_fail.t b/t/02_fail.t
deleted file mode 100644
index f73cad9..0000000
--- a/t/02_fail.t
+++ /dev/null
@@ -1,13 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-use Test::Exception;
-use lib ('t/lib');
-
-dies_ok { require FakeAPIFail }
-"... can't declare a required param that have not been declared";
-
-dies_ok {require FakeAPIFail2 }
-"... can't declare a required param that have not been declared";
-
-done_testing;
diff --git a/t/03_identica.t b/t/03_identica.t
deleted file mode 100644
index 2dc5acc..0000000
--- a/t/03_identica.t
+++ /dev/null
@@ -1,24 +0,0 @@
-use strict;
-use warnings;
-use lib ('t/lib');
-
-use Test::More;
-use Identica;
-
-BEGIN {
-    plan skip_all =>
-        'set $ENV{IDENTICA_USER} and $ENV{IDENTICA_PWD} for this test'
-        unless $ENV{IDENTICA_USER} && $ENV{IDENTICA_PWD};
-}
-
-my ($obj, $res);
-
-ok $obj = Identica->new(
-    api_username => $ENV{IDENTICA_USER},
-    api_password => $ENV{IDENTICA_PWD}
-);
-
-ok $res = $obj->public_timeline;
-ok $res = $obj->update_status( status => 'this is a test' );
-
-done_testing();
diff --git a/t/04_wow.t b/t/04_wow.t
deleted file mode 100644
index ea87d8c..0000000
--- a/t/04_wow.t
+++ /dev/null
@@ -1,16 +0,0 @@
-use strict;
-use warnings;
-use lib ('t/lib');
-
-use Test::More;
-use WoWArmory;
-
-my ( $obj, $res );
-
-ok $obj = WoWArmory->new();
-
-ok $res = $obj->character( r => 'Elune', n => 'Aarnn' );
-is $res->{characterInfo}->{character}->{name}, 'Aarnn',
-    '... got valid player name';
-done_testing();
-
diff --git a/t/10_mx_net_api_test.t b/t/10_mx_net_api_test.t
deleted file mode 100644
index 96bf2be..0000000
--- a/t/10_mx_net_api_test.t
+++ /dev/null
@@ -1,43 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-BEGIN {
-    plan skip_all => 'requires Catalyst::Action::REST'
-        unless eval { require Catalyst::Action::REST };
-}
-
-{
-
-    package catalysttestapi;
-    use Moose;
-    use MooseX::Net::API::Test;
-
-    test_api_declare 'TestAPI' => (
-        catalyst          => 1,
-        catalyst_app_name => 'TestApp'
-    );
-
-    test_api_method foo => (
-        tests => {
-            simple => [
-                {
-                    # pouvoir surcharger
-                    test     => 'is_deeply',
-                    expected => { status => 1 }
-                },
-                'ok',
-            ]
-        }
-    );
-}
-
-#content_like    => [ { expected => qr/status: 1/ }, ],
-#action_ok       => [],
-#action_redirect => [],
-#action_notfound => [],
-#contenttype_is  => [],
-
-catalysttestapi->run();
-
-done_testing;