devtools/testlib.py
changeset 4016 250784a2d105
parent 3998 94cc7cad3d2d
child 4036 137be4878127
--- a/devtools/testlib.py	Tue Dec 08 09:10:39 2009 +0100
+++ b/devtools/testlib.py	Tue Dec 08 09:38:14 2009 +0100
@@ -353,38 +353,6 @@
     def entity(self, rql, args=None, eidkey=None, req=None):
         return self.execute(rql, args, eidkey, req=req).get_entity(0, 0)
 
-    def add_entity(self, etype, req=None, **kwargs):
-        rql = ['INSERT %s X' % etype]
-        # dict for replacement in RQL Request
-        args = {}
-        if kwargs:
-            rql.append(':')
-            # dict to define new entities variables
-            entities = {}
-            # assignement part of the request
-            sub_rql = []
-            for key, value in kwargs.iteritems():
-                # entities
-                if hasattr(value, 'eid'):
-                    new_value = "%s__" % key.upper()
-                    entities[new_value] = value.eid
-                    args[new_value] = value.eid
-
-                    sub_rql.append("X %s %s" % (key, new_value))
-                # final attributes
-                else:
-                    sub_rql.append('X %s %%(%s)s' % (key, key))
-                    args[key] = value
-            rql.append(', '.join(sub_rql))
-            if entities:
-                rql.append('WHERE')
-                # WHERE part of the request (to link entity to they eid)
-                sub_rql = []
-                for key, value in entities.iteritems():
-                    sub_rql.append("%s eid %%(%s)s" % (key, key))
-                rql.append(', '.join(sub_rql))
-        return self.execute(' '.join(rql), args, req=req).get_entity(0, 0)
-
     # vregistry inspection utilities ###########################################
 
     def pviews(self, req, rset):
@@ -689,6 +657,12 @@
 
     # deprecated ###############################################################
 
+    @deprecated('[3.6] use self.request().create_entity(...)')
+    def add_entity(self, etype, req=None, **kwargs):
+        if req is None:
+            req = self.request()
+        return req.create_entity(etype, **kwargs)
+
     @deprecated('[3.4] use self.vreg["etypes"].etype_class(etype)(self.request())')
     def etype_instance(self, etype, req=None):
         req = req or self.request()