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

[test] Add a test case for yams_component_target predicate

parent cd3ba66cecb3
......@@ -36,6 +36,7 @@ from cubicweb_jsonschema.mappers import (
JSONSchemaDeserializer,
JSONSchemaSerializer,
CompoundMapper,
yams_component_target,
yams_match
)
......@@ -1666,6 +1667,32 @@ class PredicatesTC(CubicWebTC):
target_types={'Bytes'}),
4)
def test_yams_component_target(self):
predicate = yams_component_target()
with self.admin_access.cnx() as cnx:
# 'thumbnail' is composite='subject'.
self.assertEqual(
predicate(None, cnx, rtype='thumbnail', role='subject',
etype='Photo'),
1,
)
self.assertEqual(
predicate(None, cnx, rtype='thumbnail', role='object',
etype='Thumbnail'),
0,
)
# 'topics' is not composite.
self.assertEqual(
predicate(None, cnx, rtype='topics', role='subject',
etype='Book'),
0,
)
self.assertEqual(
predicate(None, cnx, rtype='topics', role='object',
etype='Topic'),
0,
)
if __name__ == '__main__':
unittest.main()
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