forked from plainblack/Lacuna-Server-Open
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path140_Entertainment.t
41 lines (33 loc) · 1.28 KB
/
140_Entertainment.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use lib '../lib';
use Test::More tests => 5;
use Test::Deep;
use Data::Dumper;
use 5.010;
use DateTime;
use TestHelper;
TestHelper->clear_all_test_empires;
my $tester = TestHelper->new->generate_test_empire->build_infrastructure;
my $session_id = $tester->session->id;
my $empire = $tester->empire;
my $home = $empire->home_planet;
my $cache = Lacuna->cache;
my $ymd = DateTime->now->ymd;
my $result;
$result = $tester->post('entertainment', 'build', [$session_id, $home->id, 0, 3]);
ok($result->{result}{building}{id}, "built an ed");
my $ed = $tester->get_building($result->{result}{building}{id});
$ed->finish_upgrade;
$result = $tester->post('entertainment', 'get_lottery_voting_options', [$session_id, $ed->id]);
is($result->{result}{options}[0]{name}, Lacuna->config->get('voting_sites')->[0]{name}, "got lottery voting options");
my $ua = $tester->ua;
$ua->requests_redirectable([]);
my $response = $ua->get($result->{result}{options}[0]{url});
is($response->code, 302, 'get a redirect');
my $zone = $ed->body->zone;
ok($cache->get('high_vote'.$zone, $ymd), 'high_vote gets set');
ok($cache->get('high_vote_empire'.$zone, $ymd), 'high_vote_empire gets set');
END {
TestHelper->clear_all_test_empires;
$cache->set('high_vote'.$zone, $ymd);
$cache->set('high_vote_empire'.$zone, $ymd);
}