def test_4(self): """ test parent/child relationship """ node = Node() node.name = "tmp2" node.content = {"user":"******"} req = json.dumps({"data":node.serialize(), "db":"test"}) _data = u"bfs : api : node.save : %s" % req self.socket.send_string(_data) reply = self.socket.recv_string() msg_data = json.loads(reply) self.assertTrue(msg_data["status"] == 'ok') child_id = str(msg_data["data"]) # get parent node query = {"__header__.name":"/"} req = json.dumps({"query":query, "db":"test", "fields":["_id"]}) _data = u"bfs : api : node.get : %s" % req self.socket.send_string(_data) reply = self.socket.recv_string() msg_data = json.loads(reply) self.assertTrue(msg_data["status"] == 'ok') parent_id = str(msg_data["data"]["_id"]) # create link req = json.dumps({"parent_docId":parent_id, "child_docId":child_id, "db":"test"}) _data = u"bfs : api : subnode.add : %s" % req self.socket.send_string(_data) reply = self.socket.recv_string() msg_data = json.loads(reply) self.assertTrue(msg_data["status"] == 'ok')
def test_1(self): """ test save node """ node = Node() node.name = "tmp" node.content = {"user":"******"} req = json.dumps({"data":node.serialize(), "db":"test"}) _data = u"bfs : api : node.save : %s" % req self.socket.send_string(_data) reply = self.socket.recv_string() msg_data = json.loads(reply) self.assertTrue(msg_data["status"] == 'ok')