Skip to content
Snippets Groups Projects
Commit e5e143fdec2e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

more testing

No related branches found
No related tags found
No related merge requests found
......@@ -110,9 +110,10 @@
('Student', ('Eetype',) ),
('Company', ('Eetype',) ),
('Address', ('Eetype',) ),
('Eetype', ('Eetype',) ),
)
),
'is_instance_of' : RelationSchema( ( ('Person', ('Eetype',) ),
('Student', ('Eetype',) ),
('Company', ('Eetype',) ),
('Address', ('Eetype',) ),
......@@ -113,9 +114,10 @@
)
),
'is_instance_of' : RelationSchema( ( ('Person', ('Eetype',) ),
('Student', ('Eetype',) ),
('Company', ('Eetype',) ),
('Address', ('Eetype',) ),
('Eetype', ('Eetype',) ),
)
),
'connait' : RelationSchema( (('Person', ('Person',) ),
......@@ -320,6 +322,48 @@
sols = sorted(node.children[0].solutions)
self.assertEquals(sols, [{'X': 'Company'}])
def test_non_regr_subjobj1(self):
h = self.helper
def type_from_uid(name):
self.assertEquals(name, "Societe")
return 'Eetype'
uid_func_mapping = {'name': type_from_uid}
# constant as rhs of the uid relation
node = h.parse('Any X WHERE X name "Societe", X is ISOBJ, ISSIBJ is X')
h.compute_solutions(node, uid_func_mapping, debug=DEBUG)
sols = sorted(node.children[0].solutions)
self.assertEquals(sols, [{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Address'},
{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Company'},
{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Eetype'},
{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Person'},
{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Student'}])
def test_non_regr_subjobj2(self):
h = self.helper
def type_from_uid(name):
self.assertEquals(name, "Societe")
return 'Eetype'
uid_func_mapping = {'name': type_from_uid}
node = h.parse('Any X WHERE X name "Societe", X is ISOBJ, ISSUBJ is X, X is_instance_of ISIOOBJ, ISIOSUBJ is_instance_of X')
h.compute_solutions(node, uid_func_mapping, debug=DEBUG)
select = node.children[0]
sols = sorted(select.solutions)
self.assertEquals(len(sols), 25)
def var_sols(var):
s = set()
for sol in sols:
s.add(sol.get(var))
return s
self.assertEquals(var_sols('X'), set(('Eetype',)))
self.assertEquals(var_sols('X'), select.defined_vars['X'].stinfo['possibletypes'])
self.assertEquals(var_sols('ISSUBJ'), set(('Address', 'Company', 'Eetype', 'Person', 'Student')))
self.assertEquals(var_sols('ISSUBJ'), select.defined_vars['ISSUBJ'].stinfo['possibletypes'])
self.assertEquals(var_sols('ISOBJ'), set(('Eetype',)))
self.assertEquals(var_sols('ISOBJ'), select.defined_vars['ISOBJ'].stinfo['possibletypes'])
self.assertEquals(var_sols('ISIOSUBJ'), set(('Address', 'Company', 'Eetype', 'Person', 'Student')))
self.assertEquals(var_sols('ISIOSUBJ'), select.defined_vars['ISIOSUBJ'].stinfo['possibletypes'])
self.assertEquals(var_sols('ISIOOBJ'), set(('Eetype',)))
self.assertEquals(var_sols('ISIOOBJ'), select.defined_vars['ISIOOBJ'].stinfo['possibletypes'])
def test_unusableuid_func_mapping(self):
h = self.helper
......
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