/[Search-Estraier]/trunk/t/5_Node.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

Diff of /trunk/t/5_Node.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Fri Jan 6 01:36:09 2006 UTC revision 51 by dpavlin, Fri Jan 6 13:19:50 2006 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 46;  use Test::More tests => 87;
7  use Test::Exception;  use Test::Exception;
8  use Data::Dumper;  use Data::Dumper;
9    
10  BEGIN { use_ok('Search::Estraier') };  BEGIN { use_ok('Search::Estraier') };
11    
12  my $debug = 1;  my $debug = 0;
13    
14  # name of node for test  # name of node for test
15  my $test_node = 'Search-Estraier';  my $test_node = 'Search-Estraier';
# Line 51  _END_OF_DRAFT_ Line 51  _END_OF_DRAFT_
51  #diag "draft:\n$draft";  #diag "draft:\n$draft";
52  ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft');  ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft');
53    
54    ok( $node->put_doc($doc), "put_doc data001");
55    
56  for ( 1 .. 10 ) {  for ( 1 .. 10 ) {
57          $doc->add_attr('@uri', 'test' . $_);          $doc->add_attr('@uri', 'test' . $_);
58          ok( $node->put_doc($doc), "put_doc test$_");          ok( $node->put_doc($doc), "put_doc test$_");
59          #diag $doc->dump_draft;          #diag $doc->dump_draft;
60  }  }
61    
62  ok(my $id = $node->uri_to_id( 'data001' ), 'uri_to_id');  my $id;
63    ok($id = $node->uri_to_id( 'data001' ), "uri_to_id = $id");
 ok( $node->out_doc( $id ), "out_doc $id");  
64    
65  for ( 1 .. 5 ) {  for ( 1 .. 5 ) {
66          ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_");          ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_");
67  }  }
68    
69  $doc->add_attr('@uri', 'data001');  ok($doc = $node->get_doc( $id ), 'get_doc for edit');
70  $doc->add_attr('foo', 'bar');  $doc->add_attr('foo', 'bar');
71    #diag Dumper($doc);
72  ok( $node->edit_doc( $doc ), 'edit_doc');  ok( $node->edit_doc( $doc ), 'edit_doc');
73    
74    ok( $node->out_doc( $id ), "out_doc $id");
75    
76    ok( ! $node->edit_doc( $doc ), "edit removed");
77    
78    ok(my $cond = new Search::Estraier::Condition, 'new cond');
79    ok($cond->set_phrase('girl'), 'cond set_phrase');
80    ok($cond->set_max(42), 'cond set_max');
81    ok($cond->set_order('@uri ASCD'), 'cond set_order');
82    ok($cond->add_attr('@title STRINC Material'), 'cond add_attr');
83    
84    cmp_ok($node->cond_to_query( $cond ), 'eq' , 'phrase=girl&attr1=%40title%20STRINC%20Material&order=%40uri%20ASCD&max=42&wwidth=480&hwidth=96&awidth=96', 'cond_to_query');
85    
86    ok( my $nrec = $node->search( $cond, 0 ), 'search');
87    
88    isa_ok( $nrec, 'Search::Estraier::NodeResult' );
89    
90  for ( 6 .. 10 ) {  for ( 6 .. 10 ) {
         ok( $node->get_doc( $_ ), "get_doc $_");  
91          my $uri = 'test' . $_;          my $uri = 'test' . $_;
92            ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri");
93            ok( $node->get_doc( $id ), "get_doc $id");
94          ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri");          ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri");
95          ok( my $k = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri");          cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id");
96            cmp_ok( $node->get_doc_attr_by_uri( $uri, '@uri' ), 'eq', $uri, "get_doc_attr $id");
97            ok( my $k = $node->etch_doc( $id ), "etch_doc_by_uri $uri");
98            ok( my $k2 = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri");
99            #diag Dumper($k, $k2);
100            ok( eq_hash( $k, $k2 ), "keywords");
101  }  }
102    
103    my $v;
104    ok($v = $node->name, "name: $v");
105    ok($v = $node->label, "label: $v");
106    ok($v = $node->doc_num, "doc_num: $v");
107    ok($v = $node->word_num, "word_num: $v");
108    ok($v = $node->size, "size: $v");
109    

Legend:
Removed from v.45  
changed lines
  Added in v.51

  ViewVC Help
Powered by ViewVC 1.1.26