[Zope-Checkins] CVS: Zope/lib/python/ZPublisher/tests -
test_xmlrpc.py:1.2
Tres Seaver
tseaver at zope.com
Fri Jan 16 13:19:48 EST 2004
Update of /cvs-repository/Zope/lib/python/ZPublisher/tests
In directory cvs.zope.org:/tmp/cvs-serv15330/lib/python/ZPublisher/tests
Added Files:
test_xmlrpc.py
Log Message:
- Merge test for Collector #1184
=== Zope/lib/python/ZPublisher/tests/test_xmlrpc.py 1.1 => 1.2 ===
--- /dev/null Fri Jan 16 13:19:48 2004
+++ Zope/lib/python/ZPublisher/tests/test_xmlrpc.py Fri Jan 16 13:19:47 2004
@@ -0,0 +1,53 @@
+import unittest
+
+class FauxResponse:
+
+ def __init__(self):
+ self._headers = {}
+ self._body = None
+
+ def setBody(self, body):
+ self._body = body
+
+ def setHeader(self, name, value):
+ self._headers[name] = value
+
+class FauxInstance:
+ def __init__(self, **kw):
+ self.__dict__.update(kw)
+
+class XMLRPCResponseTests(unittest.TestCase):
+
+ def _getTargetClass(self):
+ from ZPublisher.xmlrpc import Response
+ return Response
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
+ def test_setBody(self):
+
+ import xmlrpclib
+
+ body = FauxInstance(_secret='abc', public='def')
+ faux = FauxResponse()
+ response = self._makeOne(faux)
+
+ response.setBody(body)
+
+ body_str = faux._body
+ self.assertEqual(type(body_str), type(''))
+
+ as_set, method = xmlrpclib.loads(body_str)
+ as_set = as_set[0]
+
+ self.assertEqual(method, None)
+ self.failIf('_secret' in as_set.keys())
+ self.failUnless('public' in as_set.keys())
+ self.assertEqual(as_set['public'], 'def')
+
+def test_suite():
+ return unittest.TestSuite((unittest.makeSuite(XMLRPCResponseTests),))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
More information about the Zope-Checkins
mailing list