view release on metacpan or search on metacpan
lib/AnyEvent/WebService/Tracks/Todo.pm view on Meta::CPAN
package AnyEvent::WebService::Tracks::Todo;
use strict;
use warnings;
use parent 'AnyEvent::WebService::Tracks::Resource';
use Carp qw(croak);
use Scalar::Util qw(looks_like_number);
use namespace::clean;
our $VERSION = '0.02';
__PACKAGE__->readonly(qw/completed_at created_at id recurring_todo_id updated_at/);
__PACKAGE__->accessor(qw/description due notes show_from/);
# here, but not actually accessible: context_id project_id state
t/02-context.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use List::MoreUtils qw(all);
use Scalar::Util qw(looks_like_number);
use Storable qw(dclone);
use Test::AnyEvent::WebService::Tracks;
use Test::Exception;
use UNIVERSAL ();
my @orig_contexts = qw(One Two Three Four);
my @contexts = @orig_contexts;
plan tests => 47 * @contexts + 34;
t/02-context.t view on Meta::CPAN
my $run;
$run = sub {
my $name = shift @contexts;
$tracks->create_context($name, sub {
my ( $ctx ) = @_;
ok($ctx);
isa_ok($ctx, 'AnyEvent::WebService::Tracks::Context');
is($ctx->name, $name);
ok(looks_like_number $ctx->id);
isa_ok($ctx->created_at, 'DateTime');
isa_ok($ctx->updated_at, 'DateTime');
ok(looks_like_number $ctx->position);
ok(! $ctx->is_hidden);
dies_ok {
$ctx->id(0);
};
lives_ok {
$ctx->name('New Name');
};
dies_ok {
$ctx->created_at(DateTime->now);
t/02-context.t view on Meta::CPAN
my $run;
$run = sub {
my $name = shift @contexts;
$tracks->create_context(name => $name, sub {
my ( $ctx ) = @_;
ok($ctx);
isa_ok($ctx, 'AnyEvent::WebService::Tracks::Context');
is($ctx->name, $name);
ok(looks_like_number $ctx->id);
isa_ok($ctx->created_at, 'DateTime');
isa_ok($ctx->updated_at, 'DateTime');
ok(looks_like_number $ctx->position);
ok(! $ctx->is_hidden);
dies_ok {
$ctx->id(0);
};
lives_ok {
$ctx->name('New Name');
};
dies_ok {
$ctx->created_at(DateTime->now);
t/02-context.t view on Meta::CPAN
my $run;
$run = sub {
my $name = shift @contexts;
$tracks->create_context(name => $name, hide => 1, sub {
my ( $ctx ) = @_;
ok($ctx);
isa_ok($ctx, 'AnyEvent::WebService::Tracks::Context');
is($ctx->name, $name);
ok(looks_like_number $ctx->id);
isa_ok($ctx->created_at, 'DateTime');
isa_ok($ctx->updated_at, 'DateTime');
ok(looks_like_number $ctx->position);
ok($ctx->is_hidden);
dies_ok {
$ctx->id(0);
};
lives_ok {
$ctx->name('New Name');
};
dies_ok {
$ctx->created_at(DateTime->now);
t/03-project.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use List::MoreUtils qw(all);
use Scalar::Util qw(looks_like_number);
use Storable qw(dclone);
use Test::AnyEvent::WebService::Tracks;
use Test::Exception;
use UNIVERSAL ();
my @orig_projects = qw(P1 P2 P3 P4);
my @projects = @orig_projects;
plan tests => 62 * @projects + 78;
t/03-project.t view on Meta::CPAN
my $name = shift @projects;
$tracks->create_project($name, sub {
my ( $proj ) = @_;
ok($proj);
isa_ok($proj, 'AnyEvent::WebService::Tracks::Project');
is($proj->name, $name);
ok(! defined($proj->description));
ok(looks_like_number $proj->position);
ok(! defined($proj->completed_at));
ok(! $proj->is_complete);
ok(! $proj->is_hidden);
ok($proj->is_active);
isa_ok($proj->created_at, 'DateTime');
isa_ok($proj->updated_at, 'DateTime');
dies_ok {
$proj->completed_at(DateTime->now);
};
t/03-project.t view on Meta::CPAN
$run = sub {
my $name = shift @projects;
$tracks->create_project(name => $name, sub {
my ( $proj ) = @_;
ok($proj);
isa_ok($proj, 'AnyEvent::WebService::Tracks::Project');
is($proj->name, $name);
ok(! defined($proj->description));
ok(looks_like_number $proj->id);
ok(looks_like_number $proj->position);
ok(! defined($proj->completed_at));
ok(! $proj->is_complete);
ok(! $proj->is_hidden);
ok($proj->is_active);
isa_ok($proj->created_at, 'DateTime');
isa_ok($proj->updated_at, 'DateTime');
dies_ok {
$proj->completed_at(DateTime->now);
};
t/03-project.t view on Meta::CPAN
my $desc = "desc$i";
$tracks->create_project(name => $name, description => $desc, sub {
my ( $proj ) = @_;
ok($proj);
isa_ok($proj, 'AnyEvent::WebService::Tracks::Project');
is($proj->name, $name);
is($proj->description, $desc);
ok(looks_like_number $proj->position);
ok(! defined($proj->completed_at));
ok(! $proj->is_complete);
ok(! $proj->is_hidden);
ok($proj->is_active);
isa_ok($proj->created_at, 'DateTime');
isa_ok($proj->updated_at, 'DateTime');
dies_ok {
$proj->completed_at(DateTime->now);
};
t/04-todo.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use List::MoreUtils qw(all);
use Scalar::Util qw(looks_like_number);
use Storable qw(dclone);
use Test::AnyEvent::WebService::Tracks;
use Test::Exception;
use UNIVERSAL ();
my @orig_todos = ('Walk the dog', 'Finish TPS report', 'Take out the trash',
'Install Tracks');
my @todos = @orig_todos;
plan tests => 83 * @todos + 124;
t/04-todo.t view on Meta::CPAN
ok($todo);
isa_ok($todo, 'AnyEvent::WebService::Tracks::Todo');
is($todo->description, $desc);
ok(! defined($todo->due));
ok(! defined($todo->notes));
ok(! defined($todo->show_from));
ok($todo->is_active);
ok(! $todo->is_project_hidden);
ok(! $todo->is_complete);
ok(! $todo->is_deferred);
ok(looks_like_number $todo->id);
ok(! $todo->completed_at);
ok(! $todo->recurring_todo_id);
isa_ok($todo->created_at, 'DateTime');
isa_ok($todo->updated_at, 'DateTime');
dies_ok {
$todo->completed_at(DateTime->now);
};
dies_ok {
$todo->created_at(DateTime->now);
t/04-todo.t view on Meta::CPAN
ok($todo);
isa_ok($todo, 'AnyEvent::WebService::Tracks::Todo');
is($todo->description, $desc);
ok(! defined($todo->due));
ok(! defined($todo->notes));
ok(! defined($todo->show_from));
ok($todo->is_active);
ok(! $todo->is_project_hidden);
ok(! $todo->is_complete);
ok(! $todo->is_deferred);
ok(looks_like_number $todo->id);
ok(! $todo->completed_at);
ok(! $todo->recurring_todo_id);
isa_ok($todo->created_at, 'DateTime');
isa_ok($todo->updated_at, 'DateTime');
dies_ok {
$todo->completed_at(DateTime->now);
};
dies_ok {
$todo->created_at(DateTime->now);
t/04-todo.t view on Meta::CPAN
ok($todo);
isa_ok($todo, 'AnyEvent::WebService::Tracks::Todo');
is($todo->description, $desc);
is($todo->notes, $notes);
ok(! defined($todo->due));
ok(! defined($todo->show_from));
ok($todo->is_active);
ok(! $todo->is_project_hidden);
ok(! $todo->is_complete);
ok(! $todo->is_deferred);
ok(looks_like_number $todo->id);
ok(! $todo->completed_at);
ok(! $todo->recurring_todo_id);
isa_ok($todo->created_at, 'DateTime');
isa_ok($todo->updated_at, 'DateTime');
dies_ok {
$todo->completed_at(DateTime->now);
};
dies_ok {
$todo->created_at(DateTime->now);