-
Notifications
You must be signed in to change notification settings - Fork 1
/
game_modules_integration_test_nim.py
37 lines (30 loc) · 1.26 KB
/
game_modules_integration_test_nim.py
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
GAME_PATH = 'games/nim'
BOTS = ['python3 games/nim/bots/random_bot.py',
'python3 games/nim/bots/wrong_bot.py']
import config_helpers
config_helpers.initialize_game_environment(GAME_PATH)
import config
import unittest
import random
from tournament_stages.game_signature import GameSignature
from player import Player
from game_simulator import GameSimulator
class GameModulesIntegrationTests(unittest.TestCase):
def setUp(self):
signature = GameSignature()
players = [Player(command_line) for command_line in BOTS]
generator = config.Generator()
start_states = list(generator.generate_start_positions(signature,
players))
start_state = random.choice(start_states)
self._simulator = GameSimulator(players, start_state, signature)
def test_that_game_is_finished(self):
controller = self._simulator.play()
self.assertTrue(controller.is_finished)
def test_that_scores_exists_for_each_player(self):
controller = self._simulator.play()
scores = controller.get_scores()
players = self._simulator.get_players()
self.assertEqual(set(scores.keys()), set(players))
if __name__ == '__main__':
unittest.main()