Commit fa7223bf authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Return a "false" schema for creation of workflow transition when there's no choice

Previously, we no transition was possible to fire, we would return an
empty array in the "oneOf" of "name" property, which is invalid (see

So we return a "false" Boolean schema in these cases, thus clearly
indicating that no transition can be fired.
parent 1db2dd27c01e
......@@ -314,6 +314,8 @@ class TrInfoEntityMapper(ETypeMapper):
_ = self._cw._
transitions_choice = [{'enum': [], 'title': _(}
for tr in wfobj.possible_transitions()]
if not transitions_choice:
return False, None
schema = {
'type': 'object',
'properties': {
......@@ -1669,6 +1669,23 @@ class WfobjsMapperTC(CubicWebTC):
self.assertEqual(schema, expected)
def test_trinfo_creation_schema_empty(self):
with self.admin_access.cnx() as cnx:
user = self.create_user(cnx, u'bob')
mapper = self.vreg['mappers'].select(
'jsonschema.entity', cnx, etype='TrInfo',
# Take advantage of adapters being cached to patch the object
# directly.
wfobj = user.cw_adapt_to('IWorkflowable')
with patch.object(wfobj, 'possible_transitions',
return_value=[]) as patched:
schema = mapper.json_schema('creation')
expected = False
self.assertEqual(schema, expected)
def test_collection_serialize(self):
with self.admin_access.cnx() as cnx:
user = self.create_user(cnx, u'bob')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment