Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame^] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use utf8; |
| 4 | use Test::More; |
| 5 | use Mojo::Cache; |
| 6 | use lib 'lib', '../lib'; |
| 7 | use Data::Dumper; |
| 8 | |
| 9 | use File::Temp qw/tmpnam/; |
| 10 | use File::Basename 'dirname'; |
| 11 | use File::Spec::Functions 'catdir'; |
| 12 | |
| 13 | if ($ENV{SKIP_REAL}) { |
| 14 | plan skip_all => 'Skip real tests'; |
| 15 | }; |
| 16 | |
| 17 | use_ok('KorAP::XML::Krill'); |
| 18 | |
| 19 | my $file = tmpnam(); |
| 20 | |
| 21 | my $cache = Cache::FastMmap->new( |
| 22 | share_file => $file, |
| 23 | cache_size => '10m' |
| 24 | ); |
| 25 | |
| 26 | my $path = catdir(dirname(__FILE__), qw/corpus REI BNG 00128/); |
| 27 | ok(my $doc = KorAP::XML::Krill->new( |
| 28 | path => $path, |
| 29 | meta_type => 'I5', |
| 30 | cache => $cache |
| 31 | ), 'Get doc'); |
| 32 | |
| 33 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
| 34 | |
| 35 | ok(!$cache->get('REI'), 'No REI set'); |
| 36 | ok(!$cache->get('REI/BNG'), 'No REI/BNG set'); |
| 37 | ok($doc->parse); |
| 38 | ok($cache->get('REI'), 'REI set'); |
| 39 | ok($cache->get('REI/BNG'), 'REI/BNG set'); |
| 40 | |
| 41 | |
| 42 | # REI |
| 43 | my $rei = $cache->get('REI'); |
| 44 | is($rei->{S_availability}, 'CC-BY-SA'); |
| 45 | is($rei->{S_language}, 'de'); |
| 46 | is($rei->{T_corpus_title}, 'Reden und Interviews'); |
| 47 | |
| 48 | # REI/BNG |
| 49 | my $rei_bng = $cache->get('REI/BNG'); |
| 50 | |
| 51 | is($rei_bng->{S_availability}, 'CC-BY-SA'); |
| 52 | is($rei_bng->{S_language}, 'de'); |
| 53 | is($rei_bng->{T_corpus_title}, 'Reden und Interviews'); |
| 54 | is($rei_bng->{T_doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)'); |
| 55 | |
| 56 | done_testing; |
| 57 | __END__ |