diff options
author | franck cuny <franck@lumberjaph.net> | 2009-11-24 11:47:05 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2009-11-24 11:47:05 +0100 |
commit | 45e4fda71945954b4723ee97cbe409215abff7fc (patch) | |
tree | 6980e4ee0b247b78b1e98f0c97f5816b5042f67f /t | |
parent | initial commit (diff) | |
download | moosex-net-api-45e4fda71945954b4723ee97cbe409215abff7fc.tar.gz |
basic ideas
Diffstat (limited to '')
-rw-r--r-- | t/01_basic.t | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/t/01_basic.t b/t/01_basic.t new file mode 100644 index 0000000..cc6c606 --- /dev/null +++ b/t/01_basic.t @@ -0,0 +1,73 @@ +use strict; +use warnings; +use Test::More; +use YAML::Syck; + +{ + + package fake::api; + use Moose; + use MooseX::Net::API; + + has api_base_url => ( + is => 'ro', + isa => 'Str', + default => 'http://identi.ca/api', + ); + has format => ( is => 'ro', isa => 'Str', default => 'json', ); + has api_username => ( is => 'rw', isa => 'Str', ); + has api_password => ( is => 'rw', isa => 'Str', ); + has api_key => ( is => 'rw', isa => 'Str', ); + + format_query 'format' => ( mode => 'content-type' ); + + net_api_method foo => ( + description => 'this does foo', + method => 'GET', + path => '/foo/', + code => sub { my $self = shift; $self->get_foo }, + ); + + net_api_method public => ( + description => 'this does bar', + method => 'GET', + path => '/statuses/public_timeline', + ); + + sub get_foo { return 1; } +} + +{ + + package test::fake::api; + use Moose; + use MooseX::Net::API::Test; + extends 'fake::api'; + + test_api_method foo => ( + arguments => [qw//], + expect => sub { + my $self = shift; + warn Dump \@_; + } + ); +} + +my $obj = fake::api->new(); +ok $obj, '... object created'; +is $obj->foo, 1, '... get foo returns 1'; +ok my $res = $obj->public, '... get public'; + +my $test_obj = test::fake::api->new(); + +#my @methods = $obj->meta->get_all_methods; +#foreach (@methods) { + #if ( $_->name =~ /foo/ ) { + #my @foo = $_->meta->get_attribute_list; + #warn $_->name . " : " . Dump \@foo; + #} +#} + +#is $res->code, 200, '... request ok'; +#warn $res->content; +done_testing; |