summary refs log tree commit diff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lib/FakeAPI.pm70
-rw-r--r--t/lib/FakeAPIFail.pm19
-rw-r--r--t/lib/FakeAPIFail2.pm22
-rw-r--r--t/lib/Identica.pm24
-rw-r--r--t/lib/TestAPI.pm19
-rw-r--r--t/lib/TestApp.pm11
-rw-r--r--t/lib/TestApp/Controller/Root.pm16
-rw-r--r--t/lib/WoWArmory.pm25
8 files changed, 48 insertions, 158 deletions
diff --git a/t/lib/FakeAPI.pm b/t/lib/FakeAPI.pm
index 0496351..8fa6472 100644
--- a/t/lib/FakeAPI.pm
+++ b/t/lib/FakeAPI.pm
@@ -2,37 +2,63 @@ package FakeAPI;
 use Moose;
 use MooseX::Net::API;
 
-net_api_declare fake_api => (
-    base_url               => 'http://identi.ca/api',
-    format                 => 'json',
-    format_mode            => 'append',
-    require_authentication => 0,
+net_api_declare demorest => (
+    base_url       => 'http://localhost:3000/rest',
+    format         => 'json',
+    format_mode    => 'content-type',
+    authentication => 0,
+    username       => 'foo',
+    password       => 'bar',
 );
 
-net_api_method foo => (
-    description => 'this does foo',
+net_api_method users => (
+    description => 'get a list of users',
     method      => 'GET',
-    path        => '/foo/',
-    code        => sub { my $self = shift; $self->get_foo },
-    params      => [qw/bar/],
+    path        => '/users/',
+    expected    => [qw/200/],
 );
 
-net_api_method bar => (
-    description => 'this does bar',
+net_api_method get_user => (
+    description => 'fetch information about a specific user',
     method      => 'GET',
-    path        => '/bar/',
-    params      => [qw/bar baz/],
-    required    => [qw/baz/],
+    path        => '/user/$id',
+    params      => [qw/id/],
+    required    => [qw/id/],
+    expected    => [qw/200 404/],
 );
 
-net_api_method baz => (
-    description => 'this one does baztwo',
-    method      => 'BAZ',
-    path        => '/baz/',
-    params      => [qw/foo bla/],
-    required    => [qw/bla/],
+net_api_method create_user => (
+    description => 'create a new user',
+    method      => 'POST',
+    path        => '/user/',
+    params      => [qw/user nickname/],
+    required    => [qw/user nickname/],
 );
 
-sub get_foo { return 1; }
+net_api_method update_user => (
+    description => 'update information about a specific user',
+    method      => 'PUT',
+    path        => '/user/$id',
+    params      => [qw/id nickname/],
+    required    => [qw/id nickname/],
+);
+
+net_api_method delete_user => (
+    description => 'terminate an user',
+    method      => 'DELETE',
+    path        => '/user/$id',
+    params      => [qw/id/],
+    required    => [qw/id/],
+);
+
+net_api_method auth_get_user => (
+    description => 'fetch information about a specific user with authentication',
+    method         => 'GET',
+    path           => '/auth_user/$id',
+    params         => [qw/id/],
+    required       => [qw/id/],
+    expected       => [qw/200 404/],
+    authentication => 1,
+);
 
 1;
diff --git a/t/lib/FakeAPIFail.pm b/t/lib/FakeAPIFail.pm
deleted file mode 100644
index 87689bc..0000000
--- a/t/lib/FakeAPIFail.pm
+++ /dev/null
@@ -1,19 +0,0 @@
-package FakeAPI;
-use Moose;
-use MooseX::Net::API;
-
-net_api_declare fake_api => (
-    base_url               => 'http://identi.ca/api',
-    format                 => 'json',
-    format_mode            => 'content-type',
-    require_authentication => 0,
-);
-
-net_api_method foo => (
-    description => 'this does foo',
-    method      => 'GET',
-    path        => '/foo/',
-    required    => [qw/bar/],
-);
-
-1;
diff --git a/t/lib/FakeAPIFail2.pm b/t/lib/FakeAPIFail2.pm
deleted file mode 100644
index 1d1725b..0000000
--- a/t/lib/FakeAPIFail2.pm
+++ /dev/null
@@ -1,22 +0,0 @@
-package FakeAPI;
-use Moose;
-use MooseX::Net::API;
-
-net_api_declare fake_api => (
-    base_url               => 'http://identi.ca/api',
-    format                 => 'json',
-    format_mode            => 'content-type',
-    require_authentication => 0,
-);
-
-net_api_method baz => (
-    description => 'this one does baztwo',
-    method      => 'BAZ',
-    path        => '/baz/',
-    params      => [qw/foo/],
-    required    => [qw/bla/],
-);
-
-sub get_foo { return 1; }
-
-1;
diff --git a/t/lib/Identica.pm b/t/lib/Identica.pm
deleted file mode 100644
index 3772d03..0000000
--- a/t/lib/Identica.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-package Identica;
-use Moose;
-use MooseX::Net::API;
-
-has [qw/api_username api_password/] => ( is => 'ro', isa => 'Str' );
-
-net_api_declare identica => (
-    base_url       => 'http://identi.ca/api',
-    format         => 'json',
-    format_mode    => 'append',
-    authentication => 1,
-);
-net_api_method public_timeline => (
-    path   => '/statuses/public_timeline',
-    method => 'GET',
-);
-
-net_api_method update_status => (
-    path          => '/statuses/update',
-    method        => 'POST',
-    params        => [qw/status/],
-    required      => [qw/status/],
-    params_in_url => 1,
-);
diff --git a/t/lib/TestAPI.pm b/t/lib/TestAPI.pm
deleted file mode 100644
index 1f58351..0000000
--- a/t/lib/TestAPI.pm
+++ /dev/null
@@ -1,19 +0,0 @@
-package TestAPI;
-use Moose;
-use MooseX::Net::API;
-
-net_api_declare fake_api => (
-    base_url               => 'http://localhost/root',
-    format                 => 'json',
-    format_mode            => 'content-type',
-    require_authentication => 0,
-);
-
-net_api_method foo => (
-    description => 'this does foo',
-    method      => 'GET',
-    path        => '/foo/',
-);
-
-1;
-
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm
deleted file mode 100644
index 69ec93d..0000000
--- a/t/lib/TestApp.pm
+++ /dev/null
@@ -1,11 +0,0 @@
-package TestApp;
-use strict;
-use warnings;
-
-use Catalyst;
-
-__PACKAGE__->config( name => 'TestApp', );
-
-__PACKAGE__->setup;
-
-1;
diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm
deleted file mode 100644
index 7ea3f25..0000000
--- a/t/lib/TestApp/Controller/Root.pm
+++ /dev/null
@@ -1,16 +0,0 @@
-package TestApp::Controller::Root;
-
-use strict;
-use warnings;
-use base qw/Catalyst::Controller::REST/;
-
-sub foo : Local : ActionClass('REST') {
-    my ( $self, $c ) = @_;
-}
-
-sub foo_GET {
-    my ( $self, $c ) = @_;
-    $self->status_ok( $c, entity => { status => 1 } );
-}
-
-1;
diff --git a/t/lib/WoWArmory.pm b/t/lib/WoWArmory.pm
deleted file mode 100644
index c2715d1..0000000
--- a/t/lib/WoWArmory.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package WoWArmory;
-use Moose;
-use MooseX::Net::API;
-use LWP::UserAgent;
-
-net_api_declare wowarmory => (
-    base_url    => 'http://eu.wowarmory.com/',
-    format      => 'xml',
-    format_mode => 'append',
-    useragent   => sub {
-        my $ua = LWP::UserAgent->new;
-        $ua->agent(
-            "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
-        );
-        return $ua;
-    },
-);
-
-net_api_method character => (
-    method   => 'GET',
-    path     => '/character-sheet',
-    params   => [qw/r n/],
-    required => [qw/r n/],
-);
-1;