blob: 14e3826127d75e5af7212443976b3c28663fab3e [file] [log] [blame]
Akronb0c88db2016-06-29 16:33:18 +02001use strict;
2use warnings;
3use utf8;
4use Test::More;
5use Mojo::Cache;
6use lib 'lib', '../lib';
7use Data::Dumper;
8
9use File::Temp qw/tmpnam/;
10use File::Basename 'dirname';
11use File::Spec::Functions 'catdir';
12
13use_ok('KorAP::XML::Krill');
14
15my $file = tmpnam();
16
17my $cache = Cache::FastMmap->new(
18 share_file => $file,
19 cache_size => '10m'
20);
21
22my $path = catdir(dirname(__FILE__), qw/corpus REI BNG 00128/);
23ok(my $doc = KorAP::XML::Krill->new(
24 path => $path,
25 meta_type => 'I5',
26 cache => $cache
27), 'Get doc');
28
Nils Diewaldb3e9ccd2016-10-24 15:16:52 +020029like($doc->path, qr!\Q$path\E/!, 'Path');
Akronb0c88db2016-06-29 16:33:18 +020030
31ok(!$cache->get('REI'), 'No REI set');
32ok(!$cache->get('REI/BNG'), 'No REI/BNG set');
33ok($doc->parse);
34ok($cache->get('REI'), 'REI set');
35ok($cache->get('REI/BNG'), 'REI/BNG set');
36
37
38# REI
39my $rei = $cache->get('REI');
Akron5eb3aa02019-01-25 18:30:47 +010040is($rei->{S_availability}, 'CC-BY-SA');
41is($rei->{S_language}, 'de');
42is($rei->{T_corpus_title}, 'Reden und Interviews');
Akronb0c88db2016-06-29 16:33:18 +020043
44# REI/BNG
45my $rei_bng = $cache->get('REI/BNG');
46
Akron5eb3aa02019-01-25 18:30:47 +010047is($rei_bng->{S_availability}, 'CC-BY-SA');
48is($rei_bng->{S_language}, 'de');
49is($rei_bng->{T_corpus_title}, 'Reden und Interviews');
50is($rei_bng->{T_doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)');
Akronb0c88db2016-06-29 16:33:18 +020051
52done_testing;
53__END__