fix tests
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 11 Feb 2010 16:42:02 +0100
changeset 491 ca9fb10f9cf3
parent 486 5cb31b7a463e
child 492 63430a82aaf8
fix tests
test/unittest_analyze.py
test/unittest_nodes.py
--- a/test/unittest_analyze.py	Wed Feb 10 08:35:45 2010 +0100
+++ b/test/unittest_analyze.py	Thu Feb 11 16:42:02 2010 +0100
@@ -1,4 +1,4 @@
-from logilab.common.testlib import TestCase, unittest_main
+from logilab.common.testlib import TestCase, unittest_main, mock_object as mock
 
 from rql import RQLHelper, TypeResolverException
 
@@ -21,13 +21,10 @@
     def __init__(self, assoc_types, symmetric=False, card=None):
         self.assoc_types = assoc_types
         self.subj_types = [e_type[0] for e_type in assoc_types]
-        self.final = False
         d = {}
         for e_type, dest_types in assoc_types:
             for e_type in dest_types:
                 d[e_type] = 1
-                if e_type in ('Int', 'Datetime', 'String'):
-                    self.final = True
         self.obj_types = d.keys()
         self.symmetric = symmetric
         self.inlined = False
@@ -37,6 +34,11 @@
             else:
                 card = '**'
         self.card = card
+        self.rdefs = {}
+        for subjtype, dest_types in self.assoc_types:
+            for objtype in dest_types:
+                self.rdefs[(subjtype, objtype)] = mock(subject=subjtype, object=objtype, cardinality=self.card)
+
 
     def associations(self):
         return self.assoc_types
@@ -51,14 +53,6 @@
     def final(self):
         return self.obj_types[0] in FINAL_ETYPES
 
-    def iter_rdefs(self):
-        for subjtype, dest_types in self.assoc_types:
-            for objtype in dest_types:
-                yield subjtype, objtype
-
-    def rproperty(self, subj, obj, rprop):
-        assert rprop == 'cardinality'
-        return self.card
 
 class EntitySchema(ERSchema):
     def __init__(self, type, specialized_by=None):
--- a/test/unittest_nodes.py	Wed Feb 10 08:35:45 2010 +0100
+++ b/test/unittest_nodes.py	Thu Feb 11 16:42:02 2010 +0100
@@ -1,5 +1,7 @@
 # -*- coding: iso-8859-1 -*-
 
+from datetime import date, datetime
+
 from logilab.common.testlib import TestCase, unittest_main
 
 from rql import nodes, stmts, parse, BadRQLQuery, RQLHelper
@@ -28,8 +30,8 @@
         self.assertEquals(nodes.etype_from_pyobj(0.), 'Float')
 
     def test_datetime(self):
-        self.assertEquals(nodes.etype_from_pyobj(nodes.now()), 'Datetime')
-        self.assertEquals(nodes.etype_from_pyobj(nodes.today()), 'Datetime')
+        self.assertEquals(nodes.etype_from_pyobj(datetime.now()), 'Datetime')
+        self.assertEquals(nodes.etype_from_pyobj(date.today()), 'Date')
 
     def test_string(self):
         self.assertEquals(nodes.etype_from_pyobj('hop'), 'String')