blob: 5a216c696c2809e5b5184cd3e40266c8e2ed3cb2 [file] [log] [blame]
use strict;
use warnings;
use Test::More tests=>8;
use Mojo::JSON qw(decode_json encode_json to_json);
use REST::Client;
use Data::Dump qw(dump);
my $pid = fork();
my $res;
unless ($pid) {
unless (fork) {
exec "MOJO_CONFIG=../example.conf morbo script/derekovecs-server";
die "exec failed!";
}
exit(0);
}
sleep(20);
my $client = REST::Client->new();
$client->GET('http://localhost:3000/?word=Grund&json=1');
$res = decode_json($client->responseContent());
is( $res->{list}->[0]->[1]->{word}, "Reaktion", "primary paradigmatic neighbour of Grund" );
is( $res->{collocators}->[0]->{word}, "Hitchcock", "primary syntagmatic neighbour of Grund" );
$client->GET('http://localhost:3000/getClassicCollocators?w=Grund');
#print STDERR dump($res);
$res = decode_json($client->responseContent());
is( $res->{collocates}->[0]->{word}, "diesem", "primary collocate of Grund" );
$client->GET('http://localhost:3000/getClassicCollocators?w=Grund');
$res = decode_json($client->responseContent());
is( $res->{collocates}->[0]->{word}, "diesem", "primary collocate of Grund (cached)" );
$client->GET('http://localhost:3000/getCollocationAssociation?w=Grund&c=diesem');
$res = decode_json($client->responseContent());
is($res->{f1}, 29, "collocation association");
$client->GET('http://localhost:3000/getVersion');
$res = $client->responseContent();
like($res, qr/^"\d+\.?\d*\.?\d*"$/, "version ok");
$client->GET('http://localhost:3000/getModelName');
$res = $client->responseContent();
is($res, '"wpd19_10000"', "model name ok");
$client->GET('http://localhost:3000/getVocabSize');
$res = $client->responseContent();
ok($res > 1000, "vocab size ok");
for (my $i=0; $i<4; $i++) {
$pid++;
print STDERR "killing PID $pid\n";
system("kill -9 $pid");
}
done_testing;