def test_fix__nofix_1(): with open(os.path.dirname(__file__) + "/data/NA-3023745286.json", "r") as f: data = json.load(f) fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"]) for k, p in enumerate(data["participants"]): assert p["timeline"] == fixed_data["participants"][k]["timeline"]
def test_fix_upgrade_participant_1(): with open(os.path.dirname(__file__) + "/data/NA-3023745286.json", "r") as f: data = json.load(f) fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"], True) for p in fixed_data["participants"]: assert "role" in p
def test_fix_upgrade_participant_2(): with open(os.path.dirname(__file__) + "/data/EUW-3692606327.json", "r") as f: data = json.load(f) fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"], True) for p in fixed_data["participants"]: assert "role" in p assert "goldDiffPerMinDeltas" in p["timeline"]
def test_fix_opponent_not_found_1(): with open(os.path.dirname(__file__) + "/data/EUW-4233525244.json", "r") as f: data = json.load(f) try: fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"]) assert False except: assert True
def test_fix__nofix_2(): with open(os.path.dirname(__file__) + "/data/EUW-3692606327.json", "r") as f: data = json.load(f) fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"]) for k, p in enumerate(data["participants"]): assert p["timeline"] == fixed_data["participants"][k]["timeline"] #Does not upgrade participant assert not "role" in p assert not "goldDiffPerMinDeltas" in p["timeline"]
def test_fix_upgrade_timeline_2(): with open(os.path.dirname(__file__) + "/data/EUW-3692606327.json", "r") as f: data = json.load(f) fixed_data, fixed_timeline = roleml.fix_and_augment_game_and_timeline( data, data["timeline"], False, True) for p in fixed_data["participants"]: assert not "role" in p assert not "goldDiffPerMinDeltas" in p["timeline"] for frame in fixed_timeline["frames"]: for k, p in frame["participantFrames"].items(): assert "totalGoldDiff" in p assert "xpDiff" in p assert "minionsKilledDiff" in p assert "jungleMinionsKilledDiff" in p
def test_full(match_dto, timeline_game_id_platform_id): timeline, game_id, platform_id = timeline_game_id_platform_id match_dto, timeline = roleml.fix_and_augment_game_and_timeline( match_dto, timeline, True, True) game_match = match_to_game(match_dto) game_timeline = match_timeline_to_game(timeline, game_id, platform_id) game_full = lol_dto.utilities.merge_games(game_match, game_timeline) with open(os.path.join("json_examples", "game_merged.json"), "w+") as file: json.dump(game_full, file, indent=4) assert game_full["sources"]["riotLolApi"]["gameId"] == game_id assert game_full["teams"]["BLUE"]["players"][0]["snapshots"].__len__() > 0 assert game_full["duration"] assert game_full["patch"] return game_full