Akron | b0c88db | 2016-06-29 16:33:18 +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 | use_ok('KorAP::XML::Krill'); |
| 14 | |
| 15 | my $file = tmpnam(); |
| 16 | |
| 17 | my $cache = Cache::FastMmap->new( |
| 18 | share_file => $file, |
| 19 | cache_size => '10m' |
| 20 | ); |
| 21 | |
| 22 | my $path = catdir(dirname(__FILE__), qw/corpus REI BNG 00128/); |
| 23 | ok(my $doc = KorAP::XML::Krill->new( |
| 24 | path => $path, |
| 25 | meta_type => 'I5', |
| 26 | cache => $cache |
| 27 | ), 'Get doc'); |
| 28 | |
| 29 | like($doc->path, qr!$path/!, 'Path'); |
| 30 | |
| 31 | ok(!$cache->get('REI'), 'No REI set'); |
| 32 | ok(!$cache->get('REI/BNG'), 'No REI/BNG set'); |
| 33 | ok($doc->parse); |
| 34 | ok($cache->get('REI'), 'REI set'); |
| 35 | ok($cache->get('REI/BNG'), 'REI/BNG set'); |
| 36 | |
| 37 | |
| 38 | # REI |
| 39 | my $rei = $cache->get('REI'); |
| 40 | is($rei->{availability}, 'CC-BY-SA'); |
| 41 | is($rei->{language}, 'de'); |
| 42 | is($rei->{corpus_title}, 'Reden und Interviews'); |
| 43 | |
| 44 | # REI/BNG |
| 45 | my $rei_bng = $cache->get('REI/BNG'); |
| 46 | |
| 47 | is($rei_bng->{availability}, 'CC-BY-SA'); |
| 48 | is($rei_bng->{language}, 'de'); |
| 49 | is($rei_bng->{corpus_title}, 'Reden und Interviews'); |
| 50 | is($rei_bng->{doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)'); |
| 51 | |
| 52 | done_testing; |
| 53 | __END__ |