def path(self, id, type, params): path = [] while True: doc = self._getResource(id, type) if doc is None: raise RestException('Invalid resource id.') name = self._getResourceName(type, doc) path.insert(0, name) if type in ('file', 'item', 'folder'): id, type = self._getResourceParent(type, doc) else: break path.insert(0, type) return '/' + path_util.join(path)
def path(self, id, params): path = [] type = params['type'] while True: doc = self._getResource(id, type) if doc is None: raise RestException('Invalid resource id.') name = self._getResourceName(type, doc) path.insert(0, name) if type in ('file', 'item', 'folder'): id, type = self._getResourceParent(type, doc) else: break path.insert(0, type) return '/' + path_util.join(path)
def testJoinTokens(self): for pth, tokens in paths: self.assertEqual(path.join(tokens), pth)
def testSplitAndJoin(pth, tokens): assert path.split(pth) == tokens assert path.join(tokens) == pth