blob: a0787faa224658314e99deb6842f64d14ab0ef63 [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 Diewald0e489772016-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');
40is($rei->{availability}, 'CC-BY-SA');
41is($rei->{language}, 'de');
42is($rei->{corpus_title}, 'Reden und Interviews');
43
44# REI/BNG
45my $rei_bng = $cache->get('REI/BNG');
46
47is($rei_bng->{availability}, 'CC-BY-SA');
48is($rei_bng->{language}, 'de');
49is($rei_bng->{corpus_title}, 'Reden und Interviews');
50is($rei_bng->{doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)');
51
52done_testing;
53__END__