Exemplo n.º 1
0
    def test_6(self):
        """ test node copy """
        # get node
        query = {"__header__.name":"tmp"}
        r = sdk.cmd_getnode(query=query,db="test",fields=[])
        node_id = r["_id"]

        # get destination parent node
        query = {"__header__.name":"/"}
        r = sdk.cmd_getnode(query=query,db="test",fields=["_id"])
        parent_id = r["_id"]

        # copy node
        query = {"__header__.name":"tmp"}
        r = sdk.cmd_copynode(docId=node_id,parentId=parent_id,db="test")
        self.assertTrue(r)

        # get child nodes
        r = sdk.cmd_childnodes(docId=parent_id,db="test",fields=[])
        self.assertTrue(len(r) == 2)

        testlist = []
        for node in r:
            testlist.append(node["user"])

        self.assertTrue("ricardo" in testlist)
        self.assertTrue("jason" in testlist)
Exemplo n.º 2
0
    def test_5(self):
        """ test get child nodes """
        # get parent node
        query = {"__header__.name":"/"}
        r = sdk.cmd_getnode(query=query,db="test",fields=["_id"])
        parent_id = r["_id"]

        # get child nodes
        r = sdk.cmd_childnodes(docId=parent_id,db="test",fields=[])
        self.assertTrue(len(r) == 1)
Exemplo n.º 3
0
    def test_4(self):
        """ test parent/child relationship """
        node = common.File()
        node.name = "tmp2"
        node.content = {"user":"******"}
        r = sdk.cmd_savenode(data=node.serialize(), db="test")
        self.assertTrue(r)
        child_id = r

        # get parent node
        query = {"__header__.name":"/"}
        r = sdk.cmd_getnode(query=query,db="test",fields=["_id"])
        parent_id = r["_id"]

        # create link
        req = json.dumps({"parent_docId":parent_id,
                          "child_docId":child_id,
                          "db":"test"})
        r = sdk.cmd_addchild(parent_docId=parent_id, child_docId=child_id,db="test")
        self.assertTrue(r)
Exemplo n.º 4
0
 def test_2(self):
     """ test find node """
     query = {"__header__.name":"tmp"}
     r = sdk.cmd_getnode(query=query,db="test",fields=[])
     node = sdk.Node(r)
     self.assertTrue(node.name == 'tmp')