Exemple #1
0
    def test_integration_generate_save_check_file_count(self):
        if os.name == 'nt':
            path = 'mazes\\'
        else:
            path = 'mazes/'

        filenames = ["maze1_5x5.json", "maze2_5x5.json", "maze3_5x5.json"]
        write_test_file(path, filenames)

        new_maze = MazeFactory.generate(5, 5)
        file_management.save(new_maze, "json")

        files = file_management.get_files_in_dir("json")

        self.assertCountEqual(
            files, [
                "maze1_5x5.json", "maze2_5x5.json", "maze3_5x5.json",
                "maze4_5x5.json"
            ],
            'Should be ["maze1_5x5.json", "maze2_5x5.json", "maze3_5x5.json", "maze4_5x5.json"]'
        )

        # cleanup test files
        filenames.append('maze4_5x5.json')
        del_test_file(path, filenames)
Exemple #2
0
    def test_get_files_in_dir_only_return_expected_file_types(self):
        if os.name == 'nt':
            path = 'mazes\\'
        else:
            path = 'mazes/'

        filenames = ["maze1_15x15.json", "maze2_20x20.json", "maze3_30x30.csv"]
        write_test_file(path, filenames)

        files = file_management.get_files_in_dir("csv")
        del_test_file(path, filenames)

        self.assertCountEqual(files, ["maze3_30x30.csv"],
                              "should contain {}".format("maze3_30x30.csv"))
Exemple #3
0
    def test_get_files_in_dir_returns_expected_files(self):
        if os.name == 'nt':
            path = 'mazes\\'
        else:
            path = 'mazes/'

        filenames = [
            "maze1_15x15.json", "maze2_20x20.json", "maze3_30x30.json"
        ]
        write_test_file(path, filenames)

        files = file_management.get_files_in_dir("json")
        del_test_file(path, filenames)

        # check if the list contains expected elements, regardsless of order
        self.assertCountEqual(files, filenames,
                              "should contain {}".format(filenames))
Exemple #4
0
def get_stats_data():
    """
    Takes all files in our mazes data folder\n
    Returns all data : [[(width, height), 'solver', steps, time]]
    """
    files = get_files_in_dir("*")
    data = []
    for file in files:
        file_data = load(filename=file)
        stats_data = file_data.Stats.get_solutions()
        for stats in stats_data:
            temp_data = []
            temp_data.append(
                ((file_data.width - 1) // 2, (file_data.height - 1) // 2))
            temp_data.append(stats["algo"])
            temp_data.append(len(stats["steps"]))
            temp_data.append(stats["time"])
            data.append(temp_data)
    return data
Exemple #5
0
def get_files():
    # Always returns all files(mazes) in the directory
    return get_files_in_dir('*')