Skip to content
Snippets Groups Projects
Commit 26c0874fe199 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Add a test for graph_rql_expr() that cannot find a path

This can occur in real cases when etype is related to his parent by multiple
optional relations where only one could be filled. We could generate 'OR'
expressions but for now this is not handled.
parent 2e3fba0dacbc
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,17 @@
inlined = True
class BiographyComment(EntityType):
pass
class commented_by(RelationDefinition):
subject = 'Biography'
object = 'BiographyComment'
cardinality = '*?'
composite = 'subject'
class Event(EntityType):
"""Event in the life of an Agent, gathered in its Biography"""
......
......@@ -74,6 +74,9 @@
'Biography': {
('biography', 'object'): ['Agent'],
},
'BiographyComment': {
('commented_by', 'object'): ['Biography'],
},
'Event': {
('event', 'object'): ['Biography'],
('relates', 'object'): ['Anecdote'],
......
......@@ -35,8 +35,9 @@
('account', 'object'),
('narrated_by', 'subject'),
('comments', 'subject'),
('commented_by', 'object'),
])
self.assertEqual(structurals, expected)
expected = set([
('narrated_by', 'subject'),
('relates', 'object'),
......@@ -38,8 +39,9 @@
])
self.assertEqual(structurals, expected)
expected = set([
('narrated_by', 'subject'),
('relates', 'object'),
('commented_by', 'object'),
])
self.assertEqual(optionals, expected)
mandatories = [(str(rdef), role) for rdef, role in mandatories]
......@@ -57,6 +59,7 @@
optional = utils.optional_relations(self.schema, structure)
expected = {
'Anecdote': set([('narrated_by', 'subject')]),
'BiographyComment': set([('commented_by', 'object')]),
'Event': set([('relates', 'object')]),
}
self.assertEqual(optional, expected)
......@@ -95,6 +98,10 @@
):
self.assertEqual(utils.graph_rql_expr(self.schema, graph, etype, 'Agent'),
expected)
with self.assertRaisesRegexp(
ValueError, '^could not find a RQL path from BiographyComment to Agent$',
):
utils.graph_rql_expr(self.schema, graph, 'BiographyComment', 'Agent')
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment