/[Grep]/t/00-model-Feed.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

Annotation of /t/00-model-Feed.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 166 - (hide annotations)
Wed Jul 4 08:58:51 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1638 byte(s)
added $feed->home_page_uri which is constructed from feed URI and use it
(less useful for feeds, more useful for scrapers actually :-)
1 dpavlin 2 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the Feed model.
8    
9     =cut
10    
11 dpavlin 166 use Jifty::Test tests => 13;
12 dpavlin 2
13 dpavlin 4 use blib;
14    
15 dpavlin 2 # Make sure we can load the model
16     use_ok('Grep::Model::Feed');
17    
18     # Grab a system user
19     my $system_user = Grep::CurrentUser->superuser;
20     ok($system_user, "Found a system user");
21    
22     # Try testing a create
23     my $o = Grep::Model::Feed->new(current_user => $system_user);
24 dpavlin 4 my ($id) = $o->create(
25     uri => 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13?search_term=%s',
26     title => 'rot13.org wiki',
27    
28     );
29 dpavlin 2 ok($id, "Feed create returned success");
30     ok($o->id, "New Feed has valid id set");
31     is($o->id, $id, "Create returned the right id");
32    
33 dpavlin 166 cmp_ok( $o->search_uri('foobar'), 'eq', 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13?search_term=foobar', 'search_uri' );
34     cmp_ok( $o->home_page_uri, 'eq', 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13', 'search_uri' );
35    
36 dpavlin 2 # And another
37 dpavlin 4 $o->create(
38     uri => 'http://blog.rot13.org/',
39     title => 'my blog',
40     );
41 dpavlin 2 ok($o->id, "Feed create returned another value");
42     isnt($o->id, $id, "And it is different from the previous one");
43    
44     # Searches in general
45     my $collection = Grep::Model::FeedCollection->new(current_user => $system_user);
46     $collection->unlimit;
47     is($collection->count, 2, "Finds two records");
48    
49     # Searches in specific
50     $collection->limit(column => 'id', value => $o->id);
51     is($collection->count, 1, "Finds one record with specific id");
52    
53     # Delete one of them
54     $o->delete;
55     $collection->redo_search;
56     is($collection->count, 0, "Deleted row is gone");
57    
58     # And the other one is still there
59     $collection->unlimit;
60     is($collection->count, 1, "Still one left");
61    

  ViewVC Help
Powered by ViewVC 1.1.26