/[Grep]/t/00-action-Fetch.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /t/00-action-Fetch.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (show annotations)
Wed Jul 4 20:45:03 2007 UTC (16 years, 10 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1361 byte(s)
test Fetch action
1 #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 =head1 DESCRIPTION
6
7 A (very) basic test harness for the Fetch action.
8
9 =cut
10
11 use Jifty::Test tests => 10;
12
13 # Make sure we can load the action
14 use_ok('Grep::Action::Fetch');
15
16 # Grab a system user
17 my $system_user = Grep::CurrentUser->superuser;
18 ok($system_user, "Found a system user");
19
20 {
21 use Log::Log4perl::Level;
22 Jifty->web->log->level( $DEBUG );
23 }
24
25 my $feed = Grep::Model::Feed->new(current_user => $system_user);
26 my ($feed_id) = $feed->create(
27 uri => 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13?search_term=%s',
28 title => 'rot13.org wiki',
29 );
30 ok( $feed_id, 'feed->create' );
31
32 my $fetch = Jifty::Test->web->new_action(
33 class => 'Fetch',
34 moniker => 'fetch',
35 current_user => $system_user,
36 arguments => {}
37 );
38
39 isa_ok($fetch, 'Grep::Action::Fetch');
40
41 my %args = %{$fetch->arguments};
42
43 ok($args{q}, "Can fetch on q");
44
45 # fetch on q
46 $fetch->argument_values({ q => 'Grep test page', feed => $feed_id });
47 $fetch->run;
48
49 my $result = $fetch->result->content('items');
50
51 isa_ok($result, 'Jifty::Collection');
52 cmp_ok($result->count, '>=', 1, 'count');
53
54 diag "found ", $result->count, " results";
55
56 isa_ok( $result->first, 'Grep::Model::Item' );
57
58 is($result->first->in_feed->id, $feed_id, 'feed id');
59 like($result->first->link, qr#http://saturn.ffzg.hr/rot13#, 'link');
60
61 $feed->delete;
62

  ViewVC Help
Powered by ViewVC 1.1.26