Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
jsonschema
Commits
e7d22a6c2a56
Commit
b30b9490
authored
Mar 16, 2018
by
Denis Laxalde
Browse files
[test] Add a test case for yams_component_target predicate
parent
cd3ba66cecb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/test_mappers.py
View file @
e7d22a6c
...
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment