[PATCH 6 of 6 seda] [test] Add support for extra kwargs to scheme_for_rtype

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 31 17:08:48 CEST 2017

# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490964909 -7200
#      Fri Mar 31 14:55:09 2017 +0200
# Node ID c0e871401ee8ed4cead897f84566bcd0f494434f
# Parent  89339f79ab6dd61cf5822d14da6b9081f6ab20a6
[test] Add support for extra kwargs to scheme_for_rtype

This is useful for saem to insert its naa without redefining the whole function.

diff --git a/cubicweb_seda/testutils.py b/cubicweb_seda/testutils.py
--- a/cubicweb_seda/testutils.py
+++ b/cubicweb_seda/testutils.py
@@ -109,12 +109,15 @@ def map_cs_to_type(scheme, rtype, etype=
     if etype is not None:
         cnx.execute('SET CS scheme_entity_type ET WHERE CS eid %(cs)s, ET name %(et)s',
                     {'cs': scheme.eid, 'et': etype})
-def scheme_for_type(cnx, rtype, etype, *concept_labels):
-    scheme = cnx.create_entity('ConceptScheme', title=u'{0}/{1} vocabulary'.format(rtype, etype))
+# extra kwargs useful for client lib (e.g. saem)
+def scheme_for_type(cnx, rtype, etype, *concept_labels, **kwargs):
+    """Create a concept scheme an map it to give rtype and optional etype."""
+    scheme = cnx.create_entity('ConceptScheme', title=u'{0}/{1} vocabulary'.format(rtype, etype),
+                               **kwargs)
     map_cs_to_type(scheme, rtype, etype)
     for label in concept_labels:
     return scheme

More information about the saem-devel mailing list