3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 101; |
use Test::More tests => 115; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
32 |
|
|
33 |
SKIP: { |
SKIP: { |
34 |
|
|
35 |
skip "no $test1_node node in Hyper Estraier", 91, unless($node->name); |
skip "no $test1_node node in Hyper Estraier", 105, unless($node->name); |
36 |
|
|
37 |
my @res = ( -1, 200 ); |
my @res = ( -1, 200 ); |
38 |
|
|
100 |
|
|
101 |
cmp_ok($nres->hits, '==', $data_max, "hits"); |
cmp_ok($nres->hits, '==', $data_max, "hits"); |
102 |
|
|
103 |
for ( 6 .. 10 ) { |
for my $i ( 0 .. ($nres->hits - 1) ) { |
104 |
my $uri = 'test' . $_; |
my $uri = 'test' . ($i + $data_max + 1); |
105 |
|
|
106 |
|
if ($i < $nres->doc_num) { |
107 |
|
ok( my $rdoc = $nres->get_doc( $i ), "get_doc $i"); |
108 |
|
|
109 |
|
cmp_ok( $rdoc->attr('@uri'), 'eq', $uri, "\@uri = $uri"); |
110 |
|
ok( my $k = $rdoc->keywords( $id ), "rdoc keywords"); |
111 |
|
} |
112 |
|
|
113 |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id($uri) = $id"); |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id($uri) = $id"); |
114 |
ok( $node->get_doc( $id ), "get_doc $id"); |
ok( $node->get_doc( $id ), "get_doc $id"); |
115 |
ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); |
ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); |
116 |
cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
117 |
cmp_ok( $node->get_doc_attr_by_uri( $uri, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
cmp_ok( $node->get_doc_attr_by_uri( $uri, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
118 |
ok( my $k = $node->etch_doc( $id ), "etch_doc_by_uri $uri"); |
ok( my $k1 = $node->etch_doc( $id ), "etch_doc_by_uri $uri"); |
119 |
ok( my $k2 = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri"); |
ok( my $k2 = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri"); |
120 |
#diag Dumper($k, $k2); |
#diag Dumper($k, $k2); |
121 |
ok( eq_hash( $k, $k2 ), "keywords"); |
ok( eq_hash( $k1, $k2 ), "keywords"); |
122 |
} |
} |
123 |
|
|
124 |
ok(my $hints = $nres->hints, 'hints'); |
ok(my $hints = $nres->hints, 'hints'); |
130 |
ok($v = $node->name, "name: $v"); |
ok($v = $node->name, "name: $v"); |
131 |
ok($v = $node->label, "label: $v"); |
ok($v = $node->label, "label: $v"); |
132 |
ok($v = $node->doc_num, "doc_num: $v"); |
ok($v = $node->doc_num, "doc_num: $v"); |
133 |
ok($v = $node->word_num, "word_num: $v"); |
ok(defined($v = $node->word_num), "word_num: $v"); |
134 |
ok($v = $node->size, "size: $v"); |
ok($v = $node->size, "size: $v"); |
135 |
|
|
136 |
ok($node->set_snippet_width( 100, 10, 10 ), "set_snippet_width"); |
ok($node->set_snippet_width( 100, 10, 10 ), "set_snippet_width"); |
147 |
throws_ok { $node->name } qr/404/, 'croak on error'; |
throws_ok { $node->name } qr/404/, 'croak on error'; |
148 |
|
|
149 |
# croak_on_error |
# croak_on_error |
150 |
ok($node = new Search::Estraier::Node( url => "http://localhost:1978/$test1_node", croak_on_error => 1 ), "new $test1_node"); |
ok($node = new Search::Estraier::Node( url => "http://localhost:1978/node/$test1_node", croak_on_error => 1 ), "new $test1_node"); |
151 |
|
|
152 |
ok(! $node->uri_to_id('foobar'), 'uri_to_id without croak'); |
ok(! $node->uri_to_id('foobar'), 'uri_to_id without croak'); |
153 |
|
|
154 |
|
# test users |
155 |
|
|
156 |
|
ok(! $node->admins, 'no admins'); |
157 |
|
ok(! $node->guests, 'no guests'); |
158 |
|
|
159 |
SKIP: { |
SKIP: { |
160 |
skip "no $test2_node in Hyper Estraier, skipping set_link", 2 unless (my $test2_label = $node2->label); |
skip "no $test2_node in Hyper Estraier, skipping set_link", 5 unless (my $test2_label = $node2->label); |
161 |
|
|
162 |
|
my $link_url = "http://localhost:1978/node/$test2_node"; |
163 |
|
|
164 |
|
ok($node->set_link( $link_url, $test2_label, 42), "set_link $test2_node ($test2_label) 42"); |
165 |
|
|
166 |
|
ok(my $links = $node->links, 'links'); |
167 |
|
|
168 |
|
cmp_ok($#{$links}, '==', 0, 'one link'); |
169 |
|
|
170 |
|
like($links->[0], qr/^$link_url/, 'link correct'); |
171 |
|
|
|
ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 42), "set_link $test2_node ($test2_label) 42"); |
|
172 |
ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); |
ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); |
173 |
} # SKIP 2 |
} # SKIP 2 |
174 |
|
|