[Zope3-checkins] CVS: Zope3/src/zope/app/dublincore/tests - test_xmlmetadata.py:1.2

Fred L. Drake, Jr. fred at zope.com
Wed Aug 27 01:47:56 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/dublincore/tests
In directory cvs.zope.org:/tmp/cvs-serv28810

Modified Files:
	test_xmlmetadata.py 
Log Message:
added some preliminary tests of the serializer; the serialization is
checked by round-tripping back through the de-serializer (which is
tested more directly)


=== Zope3/src/zope/app/dublincore/tests/test_xmlmetadata.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/dublincore/tests/test_xmlmetadata.py:1.1	Wed Aug 20 17:25:15 2003
+++ Zope3/src/zope/app/dublincore/tests/test_xmlmetadata.py	Wed Aug 27 00:47:55 2003
@@ -19,7 +19,7 @@
 import unittest
 
 from zope.app.dublincore import dcterms
-from zope.app.dublincore.xmlmetadata import parseString
+from zope.app.dublincore.xmlmetadata import dumpString, parseString
 
 
 # XXX still need tests for the serializer
@@ -270,9 +270,27 @@
         self.assertRaises(ValueError, self.parse,
                           "<d:type s:type='t:DCMIType'>flub</d:type>")
 
+class XMLDublinCoreSerializationTests(unittest.TestCase):
+
+    def roundtrip(self, mapping):
+        text = dumpString(mapping)
+        parsed = parseString(text)
+        self.assertEqual(parsed, mapping)
+
+    def test_serialize_empty(self):
+        self.roundtrip({})
+
+    def test_single_entry(self):
+        self.roundtrip({"Title.Alternative": (u"Foo",)})
+
+    def test_two_titles(self):
+        self.roundtrip({"Title": (u"Foo", u"Bar")})
+
 
 def test_suite():
-    return unittest.makeSuite(XMLDublinCoreLoadingTests)
+    suite = unittest.makeSuite(XMLDublinCoreLoadingTests)
+    suite.addTest(unittest.makeSuite(XMLDublinCoreSerializationTests))
+    return suite
 
 if __name__ == "__main__":
     unittest.main(defaultTest="test_suite")




More information about the Zope3-Checkins mailing list