예제 #1
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
예제 #2
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