Exemplo n.º 1
0
    def test_file_ids_as_tree(self):
        """Test file_ids_as_tree"""
        file_ids = []
        file_ids.append(FileId(filename='../damn-test-files/mesh/blender/cube1.blend'))
        file_ids.append(FileId(filename='../../image/jpg/crate10b.jpg'))
        file_ids.append(FileId(filename='../../image/jpg/crate10.jpg'))

        main_dict = file_ids_as_tree(file_ids, '../damn-test-files/mesh/blender')

        prettify(main_dict)
        assert True
Exemplo n.º 2
0
    def test_file_ids_as_tree(self):
        """Test file_ids_as_tree"""
        file_ids = []
        file_ids.append(FileId(filename="../damn-test-files/mesh/blender/cube1.blend"))
        file_ids.append(FileId(filename="../../image/jpg/crate10b.jpg"))
        file_ids.append(FileId(filename="../../image/jpg/crate10.jpg"))

        main_dict = file_ids_as_tree(file_ids, "../damn-test-files/mesh/blender")

        prettify(main_dict)
        assert True
Exemplo n.º 3
0
    def test_find_path_for_file_id(self):
        """Test find_path_for_file_id"""
        file_ids = []
        file_ids.append(FileId(hash='1', filename='../damn-test-files/mesh/blender/cube1.blend'))
        file_ids.append(FileId(hash='2', filename='../../image/jpg/crate10b.jpg'))
        file_ids.append(FileId(hash='3', filename='../../image/jpg/crate10.jpg'))

        main_dict = file_ids_as_tree(file_ids, '../damn-test-files/mesh/blender')

        prettify(main_dict)

        assert '_/_/cube1.blend' == find_path_for_file_id(main_dict, file_ids[0])
        assert 'image/jpg/crate10b.jpg' == find_path_for_file_id(main_dict, file_ids[1])
        assert 'image/jpg/crate10.jpg' == find_path_for_file_id(main_dict, file_ids[2])
Exemplo n.º 4
0
    def test_find_path_for_file_id(self):
        """Test find_path_for_file_id"""
        file_ids = []
        file_ids.append(FileId(hash="1", filename="../damn-test-files/mesh/blender/cube1.blend"))
        file_ids.append(FileId(hash="2", filename="../../image/jpg/crate10b.jpg"))
        file_ids.append(FileId(hash="3", filename="../../image/jpg/crate10.jpg"))

        main_dict = file_ids_as_tree(file_ids, "../damn-test-files/mesh/blender")

        prettify(main_dict)

        assert "_/_/cube1.blend" == find_path_for_file_id(main_dict, file_ids[0])
        assert "image/jpg/crate10b.jpg" == find_path_for_file_id(main_dict, file_ids[1])
        assert "image/jpg/crate10.jpg" == find_path_for_file_id(main_dict, file_ids[2])
Exemplo n.º 5
0
    def test_get_files_for_path(self):
        """Test get_files_for_path"""

        file_ids = []
        file_ids.append(FileId(hash="1", filename="test.blend"))
        file_ids.append(FileId(hash="2", filename="../../image/jpeg/test-image1.jpg"))
        file_ids.append(FileId(hash="3", filename="../../image/test-image2.image"))
        file_ids.append(FileId(hash="4", filename="../../image/jpeg/test-image3.jpg"))

        main_dict = file_ids_as_tree(file_ids, "")
        prettify(main_dict)

        paths = [("", 0), ("_/", 0), ("_/_/", 1), ("image/", 1), ("image/jpeg", 2)]
        for path, count in paths:
            files = get_files_for_path(main_dict, path)
            # print('path', count, path, files.get('<children>', None), isinstance(files, dict))
            if isinstance(files, dict):
                assert len(files["<children>"]) == count
            else:
                assert count == 1

        assert True
Exemplo n.º 6
0
    def test_get_files_for_path(self):
        """Test get_files_for_path"""

        file_ids = []
        file_ids.append(FileId(hash='1', filename='test.blend'))
        file_ids.append(FileId(hash='2', filename='../../image/jpeg/test-image1.jpg'))
        file_ids.append(FileId(hash='3', filename='../../image/test-image2.image'))
        file_ids.append(FileId(hash='4', filename='../../image/jpeg/test-image3.jpg'))


        main_dict = file_ids_as_tree(file_ids, '')
        prettify(main_dict)

        paths = [('', 0), ('_/', 0), ('_/_/', 1), ('image/', 1), ('image/jpeg', 2)]
        for path, count in paths:
            files = get_files_for_path(main_dict, path)
            #print('path', count, path, files.get('<children>', None), isinstance(files, dict))
            if isinstance(files, dict):
                assert len(files['<children>']) == count
            else:
                assert count == 1

        assert True