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 | |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 29 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 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'); |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 40 | is($rei->{S_availability}, 'CC-BY-SA'); |
| 41 | is($rei->{S_language}, 'de'); |
| 42 | is($rei->{T_corpus_title}, 'Reden und Interviews'); |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 43 | |
| 44 | # REI/BNG |
| 45 | my $rei_bng = $cache->get('REI/BNG'); |
| 46 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 47 | is($rei_bng->{S_availability}, 'CC-BY-SA'); |
| 48 | is($rei_bng->{S_language}, 'de'); |
| 49 | is($rei_bng->{T_corpus_title}, 'Reden und Interviews'); |
| 50 | is($rei_bng->{T_doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)'); |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 51 | |
| 52 | done_testing; |
| 53 | __END__ |