Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fp12 committed Jan 10, 2017
1 parent 470da00 commit 479ece9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
3 changes: 3 additions & 0 deletions challonge/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def _refresh_from_json(self, json_def):
t_data = json_def['tournament']
self._get_from_dict(t_data)

# view missing fields
# print([(k, v) for k, v in t_data.items() if k not in self._fields])

if 'participants' in t_data:
self._refresh_participants_from_json(t_data['participants'])
if 'matches' in t_data:
Expand Down
54 changes: 46 additions & 8 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_a_create_destroy(self):

# @unittest.skip('')
@async_test
def test_a_a_basic_options(self):
def test_aa_basic_options(self):
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name)

Expand All @@ -116,7 +116,7 @@ def test_a_a_basic_options(self):

# @unittest.skip('')
@async_test
def test_a_b_options(self):
def test_ab_options(self):
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name)

Expand All @@ -135,6 +135,9 @@ def test_a_b_options(self):
self.assertTrue(t.notify_users_when_matches_open)
self.assertTrue(t.notify_users_when_the_tournament_ends)

yield from t.set_max_participants(25)
self.assertEqual(t.signup_cap, 25)

yield from self.user.destroy_tournament(t)

# @unittest.skip('')
Expand Down Expand Up @@ -309,8 +312,8 @@ def test_g_multi_tournaments(self):
# @unittest.skip('')
@async_test
def test_h_participants_consistency(self):
random_name1 = get_random_name()
t = yield from self.user.create_tournament(random_name1, random_name1)
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name)
p1 = yield from t.add_participant('p1')
yield from t.add_participants('p2', 'p3', 'p4')
yield from t.start() # should order a refresh of participants
Expand All @@ -322,8 +325,8 @@ def test_h_participants_consistency(self):
# @unittest.skip('')
@async_test
def test_i_swiss(self):
random_name1 = get_random_name()
t = yield from self.user.create_tournament(random_name1, random_name1, challonge.TournamentType.swiss)
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name, challonge.TournamentType.swiss)
self.assertEqual(t.tournament_type, challonge.TournamentType.swiss.value)

yield from t.update_tournament_type(challonge.TournamentType.round_robin)
Expand Down Expand Up @@ -354,8 +357,8 @@ def test_i_swiss(self):
# @unittest.skip('')
@async_test
def test_j_round_robin(self):
random_name1 = get_random_name()
t = yield from self.user.create_tournament(random_name1, random_name1, challonge.TournamentType.round_robin)
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name, challonge.TournamentType.round_robin)
self.assertEqual(t.tournament_type, challonge.TournamentType.round_robin.value)

yield from t.update_tournament_type(challonge.TournamentType.swiss)
Expand All @@ -376,6 +379,41 @@ def test_j_round_robin(self):

yield from self.user.destroy_tournament(t)

# @unittest.skip('')
@async_test
def test_k_single_elim(self):
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name)
self.assertEqual(t.tournament_type, challonge.TournamentType.single_elimination.value)

yield from t.update_tournament_type(challonge.TournamentType.swiss)
self.assertNotEqual(t.tournament_type, challonge.TournamentType.single_elimination.value)

yield from t.update_tournament_type(challonge.TournamentType.single_elimination)
self.assertEqual(t.tournament_type, challonge.TournamentType.single_elimination.value)

yield from t.set_single_elim_third_place_match(True)
self.assertTrue(t.hold_third_place_match)

yield from self.user.destroy_tournament(t)

# @unittest.skip('')
@async_test
def test_l_double_elim(self):
random_name = get_random_name()
t = yield from self.user.create_tournament(random_name, random_name, challonge.TournamentType.double_elimination)
self.assertEqual(t.tournament_type, challonge.TournamentType.double_elimination.value)

yield from t.update_tournament_type(challonge.TournamentType.swiss)
self.assertNotEqual(t.tournament_type, challonge.TournamentType.double_elimination.value)

yield from t.update_tournament_type(challonge.TournamentType.double_elimination)
self.assertEqual(t.tournament_type, challonge.TournamentType.double_elimination.value)

yield from t.update_double_elim_ending(challonge.DoubleEliminationEnding.no_grand_finals)

yield from self.user.destroy_tournament(t)


# @unittest.skip('')
class MatchesTestCase(unittest.TestCase):
Expand Down

0 comments on commit 479ece9

Please sign in to comment.