def test_competitor_change(tc): fx = Allplayall_fixture(tc) status = pickle.loads(pickle.dumps(fx.comp.get_status())) config2 = default_config() del config2['competitors'][2] comp2 = allplayalls.Allplayall('testcomp') comp2.initialise_from_control_file(config2) with tc.assertRaises(CompetitionError) as ar: comp2.set_status(status) tc.assertEqual(str(ar.exception), "competitor has been removed from control file") config3 = default_config() config3['players']['t4'] = Player_config("test4") config3['competitors'][2] = 't4' comp3 = allplayalls.Allplayall('testcomp') comp3.initialise_from_control_file(config3) with tc.assertRaises(CompetitionError) as ar: comp3.set_status(status) tc.assertEqual(str(ar.exception), "competitors have changed in the control file") config4 = default_config() config4['players']['t4'] = Player_config("test4") config4['competitors'].append('t4') comp4 = allplayalls.Allplayall('testcomp') comp4.initialise_from_control_file(config4) comp4.set_status(status)
def test_basic_config(tc): comp = allplayalls.Allplayall('test') config = default_config() config['description'] = "default\nconfig" config['board_size'] = 9 config['komi'] = 0.5 config['move_limit'] = 200 config['scorer'] = 'internal' config['internal_scorer_handicap_compensation'] = 'short' config['rounds'] = 20 comp.initialise_from_control_file(config) tc.assertEqual(comp.description, "default\nconfig") comp.set_clean_status() mBvC = comp.get_tournament_results().get_matchup('BvC') tc.assertEqual(mBvC.player_1, 't2') tc.assertEqual(mBvC.player_2, 't3') tc.assertEqual(mBvC.board_size, 9) tc.assertEqual(mBvC.komi, 0.5) tc.assertEqual(mBvC.move_limit, 200) tc.assertEqual(mBvC.scorer, 'internal') tc.assertEqual(mBvC.internal_scorer_handicap_compensation, 'short') tc.assertEqual(mBvC.number_of_games, 20) tc.assertIs(mBvC.alternating, True) tc.assertIs(mBvC.handicap, None) tc.assertEqual(mBvC.handicap_style, 'fixed')
def __init__(self, tc, config=None): if config is None: config = default_config() self.tc = tc self.comp = allplayalls.Allplayall('testcomp') self.comp.initialise_from_control_file(config) self.comp.set_clean_status()
def test_default_config(tc): comp = allplayalls.Allplayall('test') config = default_config() comp.initialise_from_control_file(config) comp.set_clean_status() tr = comp.get_tournament_results() tc.assertListEqual(tr.get_matchup_ids(), ['AvB', 'AvC', 'BvC']) mBvC = tr.get_matchup('BvC') tc.assertEqual(mBvC.player_1, 't2') tc.assertEqual(mBvC.player_2, 't3') tc.assertEqual(mBvC.board_size, 13) tc.assertEqual(mBvC.komi, 7.5) tc.assertEqual(mBvC.move_limit, 1000) tc.assertEqual(mBvC.scorer, 'players') tc.assertEqual(mBvC.internal_scorer_handicap_compensation, 'full') tc.assertEqual(mBvC.number_of_games, None) tc.assertIs(mBvC.alternating, True) tc.assertIs(mBvC.handicap, None) tc.assertEqual(mBvC.handicap_style, 'fixed')
def test_duplicate_player(tc): comp = allplayalls.Allplayall('test') config = default_config() config['competitors'].append('t2') tc.assertRaisesRegexp(ControlFileError, "duplicate competitor: t2", comp.initialise_from_control_file, config)
def test_unknown_player(tc): comp = allplayalls.Allplayall('test') config = default_config() config['competitors'].append('nonex') tc.assertRaisesRegexp(ControlFileError, "competitor nonex: unknown player", comp.initialise_from_control_file, config)