1. Odd Simon Simonsen
  2. trac-rpc-mq

Commits

Olemis Lang  committed 807e2c7

TracRpc: API v2: Fixing regression in dummy protocol providers

  • Participants
  • Parent commits a866ac0
  • Branches default

Comments (0)

Files changed (1)

File t5437/t5437-protocol_api_v2-r7194.diff

View file
  • Ignore whitespace
 RPC Protocol API version 2
 
-diff -r 1f87dee9169c trunk/setup.py
---- a/trunk/setup.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/setup.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/setup.py
+--- a/trunk/setup.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/setup.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -28,7 +28,7 @@
      url='http://trac-hacks.org/wiki/XmlRpcPlugin',
      description='RPC interface to Trac',
      tests_require = test_deps,
      packages=find_packages(exclude=['*.tests']),
      package_data={
-diff -r 1f87dee9169c trunk/tracrpc/api.py
---- a/trunk/tracrpc/api.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/api.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/api.py
+--- a/trunk/tracrpc/api.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/api.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -15,19 +15,41 @@
  from trac.perm import IPermissionRequestor
  
  
  class IXMLRPCHandler(Interface):
  
-diff -r 1f87dee9169c trunk/tracrpc/json_rpc.py
---- a/trunk/tracrpc/json_rpc.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/json_rpc.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/json_rpc.py
+--- a/trunk/tracrpc/json_rpc.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/json_rpc.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -5,8 +5,9 @@
  (c) 2009      ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
  """
  
      def _json_error(self, e, c=None, r_id=None):
          """ Makes a response dictionary that is an error. """
-diff -r 1f87dee9169c trunk/tracrpc/tests/__init__.py
---- a/trunk/tracrpc/tests/__init__.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/__init__.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/tests/__init__.py
+--- a/trunk/tracrpc/tests/__init__.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/__init__.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -35,6 +35,7 @@
              print "Enabling RPC plugin and permissions..."
              env.config.set('components', 'tracrpc.*', 'enabled')
 +                raise self.failureException, "Expected %s\n\nNothing raised" % excName
 +
 +        assertRaises = failUnlessRaises
-diff -r 1f87dee9169c trunk/tracrpc/tests/api.py
---- a/trunk/tracrpc/tests/api.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/api.py	Thu Apr 15 09:42:15 2010 -0500
-@@ -100,8 +100,8 @@
+diff -r 81472780cbdd trunk/tracrpc/tests/api.py
+--- a/trunk/tracrpc/tests/api.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/api.py	Tue Apr 20 00:18:44 2010 -0500
+@@ -47,16 +47,20 @@
+             "class DummyProvider(Component):\n"
+             "    implements(IRPCProtocol)\n"
+             "    def rpc_info(self):\n"
+-            "        yield ('TEST-RPC', 'No Docs!')\n"
++            "        return ('TEST-RPC', 'No Docs!')\n"
+             "    def rpc_match(self):\n"
+             "        yield ('rpc', 'application/x-tracrpc-test')\n"
+-            "    def rpc_process(self, req, content_type):\n"
++            "    def parse_rpc_request(self, req, content_type):\n"
++            "        return {'method' : 'system.getAPIVersion'}\n"
++            "    def send_rpc_error(self, req, e):\n"
++            "        rpcreq = req.rpc\n"
++            "        req.send_error(None, template='', content_type=rpcreq['mimetype'],\n"
++            "                       status=500, env=None, data='Test failure ')\n"
++            "    def send_rpc_result(self, req, result):\n"
++            "        rpcreq = req.rpc\n"
++            "        # raise KeyError('Here')\n"
+             "        response = 'Got a result!'\n"
+-            "        req.send_response(200)\n"
+-            "        req.send_header('Content-Type', content_type)\n"
+-            "        req.send_header('Content-Length', len(response))\n"
+-            "        req.end_headers()\n"
+-            "        req.write(response)\n")
++            "        req.send(response, rpcreq['mimetype'], 200)\n")
+         rpc_testenv.restart()
+         try:
+             req = urllib2.Request(rpc_testenv.url_anon,
+@@ -65,7 +69,7 @@
+             self.assertEquals(200, resp.code)
+             self.assertEquals("Got a result!", resp.read())
+             self.assertEquals(resp.headers['Content-Type'],
+-                                                'application/x-tracrpc-test')
++                                  'application/x-tracrpc-test;charset=utf-8')
+         finally:
+             # Clean up so that provider don't affect further tests
+             os.unlink(provider)
+@@ -80,10 +84,21 @@
+             "class DummyProvider(Component):\n"
+             "    implements(IRPCProtocol)\n"
+             "    def rpc_info(self):\n"
+-            "        yield ('TEST-RPC', 'No Docs!')\n"
++            "        return ('TEST-RPC', 'No Docs!')\n"
+             "    def rpc_match(self):\n"
+             "        yield ('rpc', 'application/x-tracrpc-test')\n"
+-            "    def rpc_process(self, req, content_type):\n"
++            "    def parse_rpc_request(self, req, content_type):\n"
++            "        return {'method' : 'system.getAPIVersion'}\n"
++            "    def send_rpc_error(self, req, e):\n"
++            "        if isinstance(e, RPCError) :\n"
++            "            req.send_error(None, template='', \n"
++            "                       content_type='text/plain',\n"
++            "                       status=500, env=None, data=e.message)\n"
++            "        else :\n"
++            "            req.send_error(None, template='', \n"
++            "                       content_type='text/plain',\n"
++            "                       status=500, env=None, data='Test failure')\n"
++            "    def send_rpc_result(self, req, result):\n"
+             "        raise RPCError('No good.')")
+         rpc_testenv.restart()
+         # Make the request
+@@ -100,8 +115,8 @@
              os.unlink(provider)
              rpc_testenv.restart()
  
  if __name__ == '__main__':
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
-diff -r 1f87dee9169c trunk/tracrpc/tests/json_rpc.py
---- a/trunk/tracrpc/tests/json_rpc.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/json_rpc.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/tests/json_rpc.py
+--- a/trunk/tracrpc/tests/json_rpc.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/json_rpc.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -14,10 +14,10 @@
  from tracrpc.util import StringIO
  
  if __name__ == '__main__':
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
-diff -r 1f87dee9169c trunk/tracrpc/tests/ticket.py
---- a/trunk/tracrpc/tests/ticket.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/ticket.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/tests/ticket.py
+--- a/trunk/tracrpc/tests/ticket.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/ticket.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -12,9 +12,9 @@
  import shutil
  import time
  if __name__ == '__main__':
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
-diff -r 1f87dee9169c trunk/tracrpc/tests/wiki.py
---- a/trunk/tracrpc/tests/wiki.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/wiki.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/tests/wiki.py
+--- a/trunk/tracrpc/tests/wiki.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/wiki.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -13,10 +13,10 @@
  
  from trac.util.compat import sorted
  if __name__ == '__main__':
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
-diff -r 1f87dee9169c trunk/tracrpc/tests/xml_rpc.py
---- a/trunk/tracrpc/tests/xml_rpc.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/tests/xml_rpc.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/tests/xml_rpc.py
+--- a/trunk/tracrpc/tests/xml_rpc.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/tests/xml_rpc.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -9,9 +9,9 @@
  
  import xmlrpclib
  if __name__ == '__main__':
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
-diff -r 1f87dee9169c trunk/tracrpc/web_ui.py
---- a/trunk/tracrpc/web_ui.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/web_ui.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/web_ui.py
+--- a/trunk/tracrpc/web_ui.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/web_ui.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -6,6 +6,10 @@
  (c) 2009      ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
  """
      # ITemplateProvider methods
  
      def get_htdocs_dirs(self):
-diff -r 1f87dee9169c trunk/tracrpc/xml_rpc.py
---- a/trunk/tracrpc/xml_rpc.py	Thu Apr 15 09:30:33 2010 -0500
-+++ b/trunk/tracrpc/xml_rpc.py	Thu Apr 15 09:42:15 2010 -0500
+diff -r 81472780cbdd trunk/tracrpc/xml_rpc.py
+--- a/trunk/tracrpc/xml_rpc.py	Mon Apr 19 23:57:51 2010 -0500
++++ b/trunk/tracrpc/xml_rpc.py	Tue Apr 20 00:18:44 2010 -0500
 @@ -19,7 +19,7 @@
  from trac.util.text import to_unicode