def distributed_clean_db(empty_db): """ Distribute team numbers in an ascending way. """ team.load_file(GOOD_TEST_TEAM_FILE, False) game.load_file(GOOD_TEST_GAME_FILE) game.load_file(join(TEST_DATA_DIR, "distribution2.csv")) game.load_file(join(TEST_DATA_DIR, "distribution3.csv")) service.set_player_codes() team.set_matches() return empty_db
def test_distribution(empty_db): team.load_file(GOOD_TEST_TEAM_FILE, True, False) for t in team.Team.objects(sex="M"): assert t.number > 0, "A male team received a number lower than 1 : {}".format( t.number) assert t.number <= 84, "A male team received a number higher than 42 : {}".format( t.number) for t in team.Team.objects(sex="F"): assert t.number > 84, "A female team received a number lower than 42 : {}".format( t.number) assert t.number <= 126, "A female team received a number higher than 126 : {}".format( t.number) team.distribute_numbers(True) for t in team.Team.objects(): assert t.number > 0, "A team received a number lower than 0 : {}".format( t.number) assert t.number <= 126, "A team received a number higher than 126 : {}".format( t.number)
def test_load_wrong_team_file(empty_db): with pytest.raises(BadenException): team.load_file(WRONG_TEST_TEAM_FILE, False)
def test_load_good_team_file_and_shuffle(empty_db): team.load_file(GOOD_TEST_TEAM_FILE, True) assert team.Team.objects.count() == 126, "There must be 126 teams"