blob: 264ec53768aca146c70f613681e4ef1df2ec8823 [file] [log] [blame]
Akron414ec952020-08-03 15:48:43 +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
13if ($ENV{SKIP_REAL}) {
14 plan skip_all => 'Skip real tests';
15};
16
17use_ok('KorAP::XML::Krill');
18
19my $file = tmpnam();
20
21my $cache = Cache::FastMmap->new(
22 share_file => $file,
23 cache_size => '10m'
24);
25
26my $path = catdir(dirname(__FILE__), qw/corpus REI BNG 00128/);
27ok(my $doc = KorAP::XML::Krill->new(
28 path => $path,
29 meta_type => 'I5',
30 cache => $cache
31), 'Get doc');
32
33like($doc->path, qr!\Q$path\E/!, 'Path');
34
35ok(!$cache->get('REI'), 'No REI set');
36ok(!$cache->get('REI/BNG'), 'No REI/BNG set');
37ok($doc->parse);
38ok($cache->get('REI'), 'REI set');
39ok($cache->get('REI/BNG'), 'REI/BNG set');
40
41
42# REI
43my $rei = $cache->get('REI');
44is($rei->{S_availability}, 'CC-BY-SA');
45is($rei->{S_language}, 'de');
46is($rei->{T_corpus_title}, 'Reden und Interviews');
47
48# REI/BNG
49my $rei_bng = $cache->get('REI/BNG');
50
51is($rei_bng->{S_availability}, 'CC-BY-SA');
52is($rei_bng->{S_language}, 'de');
53is($rei_bng->{T_corpus_title}, 'Reden und Interviews');
54is($rei_bng->{T_doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)');
55
56done_testing;
57__END__