def coerce(cls, i): """ coerce either a parent and instance, a parent or an instance. If there's both a parent and an instance, the instance is relative to the parent, so resolving needs to be done by combing them We're supporting the parent/instance combo (somewhat) but don't really need it - <instance>/update works fine, and no instance is required for /create """ d = dict() # import pdb; pdb.set_trace() parent_path = "" if i.get('parent') is not None: parent_path = i['parent'] if parent_path: parent_path = '/' + parent_path d['parent'] = Node.get(parent_path) if i.get('instance') is not None: d['instance'] = Node.get(parent_path + '/' + i['instance']) return d
def test_direct_path_notfound(self, client): """ retrieve a node directly through its path """ Node.root().add("a").add("b").add("c") assert Node.get("/d/e/f") is None
def test_direct_path(self, client): """ retrieve a node directly through its path """ n = Node.root().add("a").add("b").add("c") assert Node.get("/a/b/c") == n
def test_direct_root(self, client): """ retrieve the root node directly through its path """ n = Node.root() assert Node.get("") == n