[Checkins] SVN: zopyx.smartprintng.server/branches/security/zopyx/smartprintng/server/tests.py added test for ping() xmlrpc view

Andreas Jung andreas at andreas-jung.com
Wed Jul 22 14:15:35 EDT 2009


Log message for revision 102070:
  added test for ping() xmlrpc view
  

Changed:
  U   zopyx.smartprintng.server/branches/security/zopyx/smartprintng/server/tests.py

-=-
Modified: zopyx.smartprintng.server/branches/security/zopyx/smartprintng/server/tests.py
===================================================================
--- zopyx.smartprintng.server/branches/security/zopyx/smartprintng/server/tests.py	2009-07-22 17:46:36 UTC (rev 102069)
+++ zopyx.smartprintng.server/branches/security/zopyx/smartprintng/server/tests.py	2009-07-22 18:15:35 UTC (rev 102070)
@@ -3,9 +3,16 @@
 # (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
 ##########################################################################
 
+import xmlrpclib
 import unittest
 from repoze.bfg import testing
 
+xml = """<?xml version="1.0"?>
+<methodCall>
+   <methodName>ping</methodName>
+</methodCall>
+"""
+
 class ViewTests(unittest.TestCase):
 
     """ These tests are unit tests for the view.  They test the
@@ -25,7 +32,7 @@
         """
         testing.cleanUp()
 
-    def test_my_view(self):
+    def test_index(self):
         from zopyx.smartprintng.server.views import index
         context = testing.DummyModel()
         request = testing.DummyRequest()
@@ -62,7 +69,7 @@
         """ Clear out the application registry """
         testing.cleanUp()
 
-    def test_my_view(self):
+    def test_index(self):
         from zopyx.smartprintng.server.views import index
         context = testing.DummyModel()
         request = testing.DummyRequest()
@@ -75,3 +82,17 @@
         self.assertEqual(result.headerlist[1], ('Content-Length',
                                                 str(len(body))))
 
+    def test_xmlrpc_ping(self):
+        from zopyx.smartprintng.server.views import ping
+        context = testing.DummyModel()
+        headers = dict()
+        headers['content-type'] = 'text/xml'
+        request = testing.DummyRequest(headers=headers, post=True)
+        request.body = xml
+        result = ping(context, request)
+        self.assertEqual(result.status, '200 OK')
+        body = result.app_iter[0]
+        params, methodname = xmlrpclib.loads(result.body)
+        self.assertEqual(params[0], 'zopyx.smartprintng.server')
+
+



More information about the Checkins mailing list