/[webpac2]/trunk/t/7-est.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/7-est.t

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

revision 80 by dpavlin, Mon Nov 21 14:42:16 2005 UTC revision 302 by dpavlin, Mon Dec 19 21:35:37 2005 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 16;  use Test::More tests => 12;
6  use Test::Exception;  use Test::Exception;
7  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
8  use File::Temp qw/tempdir/;  use File::Temp qw/tempdir/;
# Line 10  use Data::Dumper; Line 10  use Data::Dumper;
10  use blib;  use blib;
11    
12  BEGIN {  BEGIN {
13    use_ok( 'WebPAC::Output::Estraier' );
14  use_ok( 'WebPAC::Search::Estraier' );  use_ok( 'WebPAC::Search::Estraier' );
15  use_ok( 'Log::Log4perl' );  use_ok( 'Log::Log4perl' );
16  }  }
# Line 17  use_ok( 'Log::Log4perl' ); Line 18  use_ok( 'Log::Log4perl' );
18  Log::Log4perl::init('./conf/log.conf');  Log::Log4perl::init('./conf/log.conf');
19  ok(my $log = Log::Log4perl->get_logger('WebPAC.test'), "get_logger");  ok(my $log = Log::Log4perl->get_logger('WebPAC.test'), "get_logger");
20    
21  ok(my $est = new WebPAC::Search::Estraier(  my $config = {
22          url => 'http://localhost:1978/node/webpac2',          masterurl => 'http://localhost:1978/',
23          user => 'admin',          user => 'admin',
24          passwd => 'admin',          passwd => 'admin',
25            database => 'webpac2test',
26          encoding => 'iso-8859-2',          encoding => 'iso-8859-2',
27          log => $log,          log => $log,
28  ), "new");          debug => 0,
29    };
30    
31  my $query = 'ivan';  ok(my $est = new WebPAC::Output::Estraier( %{ $config } ), "new WebPAC::Output::Estraier");
 my $max = 3;  
32    
33  ok(my @res = $est->search(  ok(my $list = $est->master( action => 'nodelist' ), "nodelist");
34          query => $query,  
35    like($list , qr/$config->{database}/, "found $config->{database}");
36    
37    my $ds = {
38            'Source' => {
39                    'name' => 'Izvor: ',
40                    'tag' => 'Source',
41                    'display' => [ 'foo' ],
42                    'search' => [ 'demo source '],
43                    },
44            'ID' => {
45                    'name' => 'ID',
46                    'tag' => 'IDths',
47                    'search' => [ 'bar' ],
48                    'lookup_key' => [ 'bar' ],
49                    },
50            'filename' => [ 'out/thes/001.html' ],
51            'name' => 'filename',
52            'tag' => 'filename'
53    };
54    
55    ok($est->add( id => 42, ds => $ds, type => 'search' ), "add");
56    
57    ok(my $est_s = new WebPAC::Search::Estraier( %{ $config } ), "new WebPAC::Search::Estraier");
58    
59    my $query = 'demo';
60    my $max = 1;
61    
62    ok(my @res = $est_s->search(
63            phrase => $query,
64            get_attr => [ qw/ID Source/ ],
65          max => $max,          max => $max,
         attr => [ qw/PersonalName/ ],  
66  ), "search $query, max: $max");  ), "search $query, max: $max");
67    
68  cmp_ok($#res, '==', $max, "$max hits");  cmp_ok(($#res + 1), '==', $max, "$max hits");
69    
70  diag Dumper(\@res);  diag Dumper(\@res);
71    
72    ok($est->master( action => 'nodedel', name => 'webpac2test' ), "nodedel");
73    

Legend:
Removed from v.80  
changed lines
  Added in v.302

  ViewVC Help
Powered by ViewVC 1.1.26