예제 #1
0
def test_add_paths():
    tests = [(
        [
            {
                "id": "root"
            },
            [
                {
                    "id": "1",
                    "name": "sub",
                    "parents": ["root"]
                },
                {
                    "id": "2",
                    "name": "subsub",
                    "parents": ["1"]
                },
                {
                    "id": "3",
                    "name": "sub1",
                    "parents": ["root"]
                },
                {
                    "id": "4",
                    "name": "subsubsub",
                    "parents": ["2"]
                },
            ],
        ],
        [
            {
                "id": "1",
                "name": "sub",
                "parents": ["root"],
                "path": "/sub"
            },
            {
                "id": "2",
                "name": "subsub",
                "parents": ["1"],
                "path": "/sub/subsub"
            },
            {
                "id": "3",
                "name": "sub1",
                "parents": ["root"],
                "path": "/sub1"
            },
            {
                "id": "4",
                "name": "subsubsub",
                "parents": ["2"],
                "path": "/sub/subsub/subsubsub",
            },
        ],
    )]

    for test in tests:
        util.add_paths(*test[TEST])
        assert test[TEST][1] == test[ANSWER]
예제 #2
0
    def refresh_directories(self):
        """Refresh list of directories for the current user."""
        self._load_dirs = True
        q = "mimeType='application/vnd.google-apps.folder'"
        self._dirs = self._query_drive(q)
        root_dirs = []

        for dir_ in self._dirs:
            # these are top level shared drives
            if "parents" not in dir_:
                dir_["path"] = dir_["name"]
                root_dirs.append(dir_)

        for root_dir in root_dirs:
            add_paths(root_dir, self._dirs)
예제 #3
0
 def refresh_directories(self):
     """Refresh list of directories for the current user."""
     self._load_dirs = True
     q = "mimeType='application/vnd.google-apps.folder'"
     self._dirs = self._query_drive(q)
     add_paths(self._root, self._dirs)