def test_can_delete_multiple_existing_relationships(self): _id = 999 n = Node(id=_id) _id2 = 999 n2 = Node(id=_id2) _id3 = 8989 rel = Relationship(start=n, end=n2, id=_id3) _iid = 134 nn = Node(id=_iid) _id22 = 323 nn2 = Node(id=_id22) _id4 = 9991 rel2 = Relationship(start=nn, end=nn2, id=_id4) q = Query([rel, rel2]) query, params = q.delete() exp = ("MATCH ()-[{var}]-() WHERE id({var}) = ${id}" " MATCH ()-[{var2}]-() WHERE id({var2}) = ${id2}" " DELETE {var}, {var2}".format(var=rel.query_variable, id=get_dict_key(params, _id3), label=rel.type, var2=rel2.query_variable, id2=get_dict_key(params, _id4), label2=rel2.type)) self.assertEqual(exp, query) self.assertEqual(2, len(params))
def test_can_detach_delete_single_existing_node(self): _id = 999 n = Node(id=_id) q = Query(n) query, params = q.delete(detach=True) exp = "MATCH ({var}) WHERE id({var}) = ${id} DETACH DELETE {var}".format( var=n.query_variable, id=get_dict_key(params, _id)) self.assertEqual(exp, query) self.assertEqual(1, len(params))
def test_can_delete_single_existing_relationship(self): _id = 999 n = Node(id=_id) _id2 = 999 n2 = Node(id=_id2) _id3 = 8989 rel = Relationship(start=n, end=n2, id=_id3) q = Query(rel) query, params = q.delete() exp = "MATCH ()-[{var}]-() WHERE id({var}) = ${id} DELETE {var}".format( var=rel.query_variable, id=get_dict_key(params, _id3), label=rel.type) self.assertEqual(exp, query) self.assertEqual(1, len(params))
def test_can_delete_multiple_existing_nodes(self): _id = 999 n = Node(id=_id) _id2 = 777 n2 = Node(id=_id2) q = Query([n, n2]) query, params = q.delete() exp = ("MATCH ({var}) WHERE id({var}) = ${id}" " MATCH ({var2}) WHERE id({var2}) = ${id2}" " DELETE {var}, {var2}".format(var=n.query_variable, id=get_dict_key(params, _id), var2=n2.query_variable, id2=get_dict_key(params, _id2))) self.assertEqual(exp, query) self.assertEqual(2, len(params))