Author: jmorliaguet
Date: Sat Dec 17 12:27:34 2005
New Revision: 2040

Modified:
   cpsskins/branches/jmo-perspectives/tests/test_relation_io.py
Log:

- test fix



Modified: cpsskins/branches/jmo-perspectives/tests/test_relation_io.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/tests/test_relation_io.py        
(original)
+++ cpsskins/branches/jmo-perspectives/tests/test_relation_io.py        Sat Dec 
17 12:27:34 2005
@@ -20,14 +20,15 @@
 import re
 import unittest
 
+from zope.app.component.testing import PlacefulSetup
 from zope.app.testing import ztapi
 from zope.component import getMultiAdapter
 from zope.publisher.browser import TestRequest
-from zope.app.component.testing import PlacefulSetup
-from zope.app.folder import Folder
+from zope.interface import implements
 
+from cpsskins.elements.interfaces import IIdentifiable
 from cpsskins.io.interfaces import IDataExporter, IDataImporter
-from cpsskins.relations.interfaces import IRelation
+from cpsskins.relations.interfaces import IRelation, IRelatable
 from cpsskins.relations import TestRelate, Predicate
 
 def normalized(text=u''):
@@ -43,13 +44,57 @@
         self.name = name
         self.__name__ = name
 
+    def __repr__(self):
+        return '<Relate: %s>' % self.name
+
+class Identifiable(object):
+
+    implements(IIdentifiable)
+
+    def __init__(self, context):
+        self.context = context
+
+    def getURI(self):
+        return 'relate.%s' % self.context.name
+
 class TestRelation(PlacefulSetup, unittest.TestCase):
 
     def setUp(self):
         PlacefulSetup.setUp(self)
         from cpsskins.io import relation
         ztapi.browserViewProviding(IRelation, relation.Exporter, IDataExporter)
-        ztapi.provideAdapter(IRelation, relation.Importer, IDataImporter)
+        ztapi.provideAdapter(IRelation, IDataImporter, relation.Importer)
+        ztapi.provideAdapter(IRelatable, IIdentifiable, Identifiable)
+
+    def test_export_monadic_relation(self):
+        from cpsskins.relations import MonadicRelation
+        rel = MonadicRelation(predicate=Predicate(u'_ A'),
+                             first=Relate(u'first'))
+
+        exporter = getMultiAdapter((rel, TestRequest()), IDataExporter)
+        expected = u"""
+          <?xml version="1.0"?>
+          <relation predicate="_ A">
+            <relate uri="relate.first"/>
+          </relation>
+          """
+        self.assertEqual(normalized(exporter()), normalized(expected))
+
+    def test_export_dyadic_relation(self):
+        from cpsskins.relations import DyadicRelation
+        rel = DyadicRelation(predicate=Predicate(u'_ A _'),
+                              first=Relate(u'first'),
+                              second=Relate(u'second'))
+
+        exporter = getMultiAdapter((rel, TestRequest()), IDataExporter)
+        expected = u"""
+          <?xml version="1.0"?>
+          <relation predicate="_ A _">
+            <relate uri="relate.first"/>
+            <relate uri="relate.second"/>
+          </relation>
+          """
+        self.assertEqual(normalized(exporter()), normalized(expected))
 
     def test_export_triadic_relation(self):
         from cpsskins.relations import TriadicRelation
@@ -62,9 +107,9 @@
         expected = u"""
           <?xml version="1.0"?>
           <relation predicate="_ A _ B _">
-            <relate uri="first"/>
-            <relate uri="second"/>
-            <relate uri="third"/>
+            <relate uri="relate.first"/>
+            <relate uri="relate.second"/>
+            <relate uri="relate.third"/>
           </relation>
           """
         self.assertEqual(normalized(exporter()), normalized(expected))
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to