Skip to content
Snippets Groups Projects
Commit 46ea8a04429c authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

fix unwanted shared singleton making tests fail

parent 355006b88d3a
No related branches found
No related tags found
No related merge requests found
from logilab.common.testlib import TestCase, unittest_main
from rql import RQLHelper, TypeResolverException
from rql.analyze import UnifyingETypeResolver, ETypeResolver
FINAL_ETYPES = ('String', 'Boolean', 'Int', 'Float', 'Date', 'Datetime')
......@@ -5,7 +4,7 @@
FINAL_ETYPES = ('String', 'Boolean', 'Int', 'Float', 'Date', 'Datetime')
class ERSchema:
class ERSchema(object):
def __cmp__(self, other):
other = getattr(other, 'type', other)
......@@ -49,32 +48,28 @@
def is_final(self):
return self.type in FINAL_ETYPES
class DummySchema:
_types = {}
for type in ['String', 'Boolean', 'Int', 'Float', 'Date',
'Eetype', 'Person', 'Company', 'Address']:
_types[type] = EntitySchema(type)
_relations = {
'eid' : RelationSchema( ( ('Person', ('Int',) ),
('Company', ('Int',) ),
('Address', ('Int',) ),
('Eetype', ('Int',) ),
)
),
'creation_date' : RelationSchema( ( ('Person', ('Datetime',) ),
('Company', ('Datetime',) ),
('Address', ('Datetime',) ),
('Eetype', ('Datetime',) ),
)
),
'name' : RelationSchema( ( ('Person', ('String',) ),
('Company', ('String',) ),
)
),
'firstname' : RelationSchema( ( ('Person', ('String',) ),
)
),
'work_for' : RelationSchema( ( ('Person', ('Company',) ),
class DummySchema(object):
def __init__(self):
self._types = {}
for etype in ['String', 'Boolean', 'Int', 'Float', 'Date',
'Eetype', 'Person', 'Company', 'Address']:
self._types[etype] = EntitySchema(etype)
self._relations = {
'eid' : RelationSchema( ( ('Person', ('Int',) ),
('Company', ('Int',) ),
('Address', ('Int',) ),
('Eetype', ('Int',) ),
)
),
'creation_date' : RelationSchema( ( ('Person', ('Datetime',) ),
('Company', ('Datetime',) ),
('Address', ('Datetime',) ),
('Eetype', ('Datetime',) ),
)
),
'name' : RelationSchema( ( ('Person', ('String',) ),
('Company', ('String',) ),
)
),
......@@ -79,14 +74,13 @@
)
),
'is' : RelationSchema( ( ('Person', ('Eetype',) ),
('Company', ('Eetype',) ),
('Address', ('Eetype',) ),
)
),
'connait' : RelationSchema( (('Person', ('Person',) ),
),
symetric=True),
'located' : RelationSchema( ( ('Person', ('Address',) ),
('Company', ('Address',) ),
'firstname' : RelationSchema( ( ('Person', ('String',) ),
)
),
'work_for' : RelationSchema( ( ('Person', ('Company',) ),
)
),
'is' : RelationSchema( ( ('Person', ('Eetype',) ),
('Company', ('Eetype',) ),
('Address', ('Eetype',) ),
)
),
......@@ -91,17 +85,25 @@
)
),
'owned_by' : RelationSchema( ( ('Person', ('Person',) ),
('Company', ('Person',) ),
('Eetype', ('Person',) ),
)
),
'identity' : RelationSchema( ( ('Person', ('Person',) ),
('Company', ('Company',) ),
('Address', ('Address',) ),
('Eetype', ('Eetype',) ),
)
),
}
'connait' : RelationSchema( (('Person', ('Person',) ),
),
symetric=True),
'located' : RelationSchema( ( ('Person', ('Address',) ),
('Company', ('Address',) ),
)
),
'owned_by' : RelationSchema( ( ('Person', ('Person',) ),
('Company', ('Person',) ),
('Eetype', ('Person',) ),
)
),
'identity' : RelationSchema( ( ('Person', ('Person',) ),
('Company', ('Company',) ),
('Address', ('Address',) ),
('Eetype', ('Eetype',) ),
)
),
}
def entities(self):
return self._types.values()
......
......@@ -4,8 +4,4 @@
from unittest_analyze import RelationSchema, EntitySchema, DummySchema as BaseSchema
class DummySchema(BaseSchema):
_types = BaseSchema._types
for type in ['Note',]:
_types[type] = EntitySchema(type)
......@@ -11,15 +7,16 @@
_relations = BaseSchema._relations
_relations['a_faire_par'] = RelationSchema( ( ('Note', ('Person',)),
)
)
_relations['creation_date'] = RelationSchema( ( ('Note', ('Date',)),
)
)
_relations['nom'] = _relations['name']
_relations['prenom'] = _relations['firstname']
def __init__(self):
super(DummySchema, self).__init__()
for etype in ['Note',]:
self._types[etype] = EntitySchema(etype)
relations = [('a_faire_par', (('Note', ('Person',)),)),
('creation_date', (('Note', ('Date',)),)),
]
for rel_name, rel_ent in relations:
self._relations[rel_name] = RelationSchema(rel_ent)
self._relations['nom'] = self._relations['name']
self._relations['prenom'] = self._relations['firstname']
class RQLCompareClassTest(TestCase):
""" Compare RQL strings """
......
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