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

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

revision 774 by dpavlin, Fri Nov 3 20:56:21 2006 UTC revision 796 by dpavlin, Sun Feb 4 12:42:43 2007 UTC
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11  BEGIN {  BEGIN {
12  use_ok( 'WebPAC::Input::ISIS' );  use_ok( 'WebPAC::Input::ISIS' );
13  use_ok( 'WebPAC::Input::MARC' );  use_ok( 'WebPAC::Input::MARC' );
14    use_ok( 'WebPAC::Input::Test' );
15  }  }
16    
17  my $debug = shift @ARGV;  my $debug = shift @ARGV;
# Line 105  test_start_limit($input, 3, $size, $size Line 106  test_start_limit($input, 3, $size, $size
106  test_start_limit($input, 1, $size + 2, $size);  test_start_limit($input, 1, $size + 2, $size);
107    
108  ok(my $s = $input->stats, 'stats');  ok(my $s = $input->stats, 'stats');
109  diag "stats:\n$s";  diag "stats:\n$s" if ($debug);
110    
111  $module = 'WebPAC::Input::MARC';  $module = 'WebPAC::Input::MARC';
112  diag "testing with $module";  diag "testing with $module";
# Line 119  test_after_open($input); Line 120  test_after_open($input);
120  test_fetch($input, $input->size);  test_fetch($input, $input->size);
121    
122  # test modify_record  # test modify_record
123  $module = 'WebPAC::Input::ISIS';  $module = 'WebPAC::Input::Test';
124  ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");  ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module");
125    
126  ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");  ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");
127    
128    $WebPAC::Input::Test::rec = {
129            '200' => [ {
130                    'a' => 'foo',
131                    'b' => 'bar',
132                    }, {
133                    'a' => 'baz',
134                    } ],
135            '900' => [
136                    'foobar',
137                    ],
138    };
139    
140    ok($input->size, 'size');
141    
142  ok(my $rec_p = $input->fetch, 'fetch');  ok(my $rec_p = $input->fetch, 'fetch');
143    
144    # modify_records
145    
146  ok($input->open(  ok($input->open(
147          path => "$abs_path/modify_isis/LIBRI",          path => "$abs_path/modify_isis/LIBRI",
148          modify_records => {          modify_records => {
149                  200 => {                  200 => {
150                          '*' => { '^c' => '. ' },                          '*' => { '^c' => '. ' },
151                            '^f' => { ' : ' => ' / ' },
152                  }                  }
153          },          },
154  ), "open modify_isis (with modify_records)");  ), "open modify_isis (with modify_records)");
155    
156  ok(my $rec = $input->fetch, 'fetch');  ok(my $rec = $input->fetch, 'fetch');
157    diag "fetched rec field 200 = ", dump($rec->{200}) if ($debug);
158    
159  cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working');  cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working');
160    
161    diag "input = ",dump($input->{data}) if ($debug);
162    
163    # break encapsulation, bad! bad!
164    $input->{ll_db}->{_isis_db}->{record} = {
165            900 => 'foo ; bar ; baz',
166    };
167    
168    $input->{modify_record} = {
169            900 => {
170                    '*' => [
171                            { ' ; ' => 'a' },
172                            { ' ; ' => 'b' },
173                            { ' ; ' => 'c' },
174                    ],
175            }
176    };
177    
178    diag "hacked: ",dump($input, $input->fetch) if ($debug);
179    
180    # seek
181    throws_ok { $input->seek } qw/without/, 'seek without position';
182    cmp_ok($input->seek(0), '==', -1, 'seek');
183    
184    ok(my $rec = $input->fetch, 'fetch');
185    diag "fetched rec = ", dump($rec) if ($debug);

Legend:
Removed from v.774  
changed lines
  Added in v.796

  ViewVC Help
Powered by ViewVC 1.1.26