def test_generate_series(self): with patch('config.Generator') as Generator: Generator().generate_start_positions.return_value = [42] test_round = Round(players_list=[[1, 2]], game_info=Mock()) test_round._generate_series() self.assertEqual(test_round._jurystates_list[0], 42)
def test_run(self): with patch('config.Generator') as Generator: series.Series = Mock() series.Series().get_results.return_value = {'aba': 'caba'} test_round = Round(players_list=[[1, 2]], game_info=Mock()) test_round._jurystates_list = [Mock()] logger.setLevel(10050000) # logger = Mock() test_round.run() self.assertEqual(test_round.games_results, {'aba': 'caba'})
def run(self): ''' Getting results of tournament. ''' logger.info('running tournament #%d', self.tournament_id) game_signature = GameSignature(self.tournament_id) self.tournament_system = create()(self.players_list) for round_id, players in enumerate(self.tournament_system.get_rounds()): game_signature.round_id = round_id # If our tournament can give names to rounds, e.g. olympic, # we should also assign a name to the round. But it is also # possible, that get_round_name returns None. game_signature.round_name = self.tournament_system.get_round_name( round_id, len(list(self.tournament_system.get_rounds()))) _round = Round(list(players), game_signature) _round.run() _round_results = _round.games_results self.tournament_system.add_round_results(_round_results) self.results = self.tournament_system.get_all_results() logger.info('tournament #%d finished', self.tournament_id)