def populated_table():
    samples = [
        Game('Ohio State', 'Michigan', 100, 0, Date(2020, 11, 3)),
        Game('Penn State', 'Rutgers', 100, 0, Date(2020, 11, 2)),
        Game('Clemson', 'Alabama', 23, 20, Date(2020, 11, 3)),
        Game('Ohio State', 'Michigan State', 17, 7, Date(2020, 11, 3)),
    ]
    return ScorigamiTable(samples)
def sample_games():
    samples = [
        Game('Ohio State', 'Michigan', 100, 0, Date(2020, 11, 3)),
        Game('Penn State', 'Rutgers', 100, 0, Date(2020, 11, 2)),
        Game('Clemson', 'Alabama', 23, 20, Date(2020, 11, 3)),
        Game('Ohio State', 'Michigan State', 17, 7, Date(2020, 11, 3)),
    ]
    return samples
Ejemplo n.º 3
0
def test_get_games_1869_correct():
    fake_cache = get_fake_cache()
    result, years = scrape.get_games(fake_cache)

    expected = [
        Game("Rutgers", "Princeton", 6, 4, Date(1869, 11, 6)),
        Game("Princeton", "Rutgers", 8, 0, Date(1869, 11, 13))
    ]
    current_year = datetime.datetime.now().year
    expected_years = [i for i in range(1869, current_year + 1)]
    assert sorted(years) == sorted(expected_years)
    assert result[1869] == expected
def test_extract_games_useless_games(populated_table):
    expected = [
        Game('Ohio State', 'Rutgers', 100, 0, Date(2020, 11, 5)),
        Game('Penn State', 'Rutgers', 100, 0, Date(2020, 11, 2)),
        Game('Clemson', 'Alabama', 23, 20, Date(2020, 11, 3)),
        Game('Ohio State', 'Michigan State', 17, 7, Date(2020, 11, 3)),
    ]
    newest_game = Game('Ohio State', 'Rutgers', 100, 0, Date(2020, 11, 5))
    updated_table = populated_table
    updated_table.add_games([newest_game])
    result = updated_table.extract_games()
    assert sorted(result) == sorted(expected)
Ejemplo n.º 5
0
def test_from_json(sample_game):
    data = {
        "winner": "Ohio State",
        "loser": "Michigan",
        "winner_points": 100,
        "loser_points": 0,
        "date": "2020-11-05"
    }
    assert Game.from_json(data) == sample_game
Ejemplo n.º 6
0
def read_cache(file_name):
    games = []
    years = []

    cache = {}
    if os.path.exists(file_name):
        with open(file_name, 'r') as fp:
            cache = json.load(fp)
            games = [Game.from_json(game) for game in cache['games']]
            years = cache['years']

    return games, years
Ejemplo n.º 7
0
def sample_games():
    games = [
        Game("Rutgers", "Princeton", 6, 4, Date(1869, 11, 6)),
        Game("Princeton", "Rutgers", 8, 0, Date(1869, 11, 13))
    ]
    return games
Ejemplo n.º 8
0
def test_process_year_data_correct_game(sample_rows):
    games = scrape._process_year_data(sample_rows)

    expected = Game("Rutgers", "Princeton", 6, 4, Date(1869, 11, 6))
    assert games[0] == expected
def test_get_recent_game_filled(populated_table):
    newest_game = Game('Ohio State', 'Rutgers', 100, 0, Date(2020, 11, 5))
    updated_table = populated_table
    updated_table.add_games([newest_game])
    result = updated_table.get_recent_game(100, 0)
    assert result == newest_game
def test_get_first_game_filled(populated_table):
    result = populated_table.get_first_game(100, 0)
    expected = Game('Penn State', 'Rutgers', 100, 0, Date(2020, 11, 2))
    assert result == expected
def test_get_entry_filled(populated_table):
    result = populated_table.get_entry(100, 0)
    expected = TableEntry(
        'Filled', Game('Penn State', 'Rutgers', 100, 0, Date(2020, 11, 2)))
    assert result == expected
Ejemplo n.º 12
0
def sample_game():
    game = Game("Ohio State", "Michigan", 100, 0, Date(2020, 11, 5))
    return game
Ejemplo n.º 13
0
def test_tt_false(sample_game):
    other_game = Game("Rutgers", "Michigan", 99, 0, Date(2020, 9, 30))
    assert sample_game > other_game
Ejemplo n.º 14
0
def test_gt_true(sample_game):
    other_game = Game("Rutgers", "Michigan", 99, 0, Date(2020, 11, 30))
    assert not sample_game > other_game
Ejemplo n.º 15
0
def test_equal_false(sample_game):
    other_game = Game("Rutgers", "Michigan", 99, 0, Date(2020, 10, 30))
    assert sample_game != other_game
Ejemplo n.º 16
0
def test_equal_true(sample_game):
    other_game = Game("Ohio State", "Michigan", 100, 0, Date(2020, 11, 5))
    assert sample_game == other_game