コード例 #1
0
def test_compare_csv():
    temp_folder = os.path.join(os.getcwd(), 'temp')
    temp_file = os.path.join(temp_folder, 'temp.csv')
    remove_directory(temp_folder)

    assert not os.path.isfile(temp_file)
    assert not os.path.isdir(temp_folder)

    copy_csv(FINAL_FILE, temp_file)

    assert compare_csv(FINAL_FILE, temp_file)
    assert compare_csv(temp_file, temp_file)
    assert compare_csv(FINAL_FILE, FINAL_FILE)

    remove_directory(temp_folder)
def test_get_rankings_all():
    temp_folder = os.path.join(os.getcwd(), 'temp/file.csv')
    make_directory(temp_folder)

    from_year, to_year = 1993, 2019
    get_rankings_all(from_year, to_year, RAW_CLEANED_DATA_FILE_PATH, temp_folder)

    for year in range(from_year, to_year + 1):
        csv_file = '{}-{}.csv'.format(year, year + 1)
        created_file = os.path.join(temp_folder, csv_file)
        cmp_file = os.path.join(STANDINGS_PATH, csv_file)
        assert compare_csv(cmp_file, created_file)
    remove_directory(temp_folder)
def test_get_rankings_year_after_sofifa():
    year = 2008
    temp_folder = os.path.join(os.getcwd(), 'temp')
    csv_file = '{}-{}.csv'.format(year, year + 1)
    from_file = os.path.join(RAW_CLEANED_DATA_FILE_PATH, csv_file)
    to_file = os.path.join(temp_folder, csv_file)
    make_directory(temp_folder)

    get_rankings(from_file, to_file, '{}-12-31'.format(str(year+1)), include_prediction=False)

    cmp_file = os.path.join(STANDINGS_PATH, csv_file)
    assert compare_csv(cmp_file, to_file)
    remove_directory(temp_folder)
コード例 #4
0
    def diff():
        for comparison_file in comparison_files:
            current_file = comparison_file.replace("src/changed", "dist/csv")
            json_file = current_file.replace("csv", "json")

            with open(json_file, "r") as input_file:
                data = json.load(input_file)

            diff = compare_csv(current_file, comparison_file)
            node = apply_changes(data, diff)

            # Write to disk
            with open(json_file, "w") as output_file:
                json.dump(data, output_file, ensure_ascii=False, indent=4)