1. Olemis Lang
  2. bloodhound-rpc

Commits

Olemis Lang  committed 11391e4

BH RPC : Upgrade code to load JSON-RPC test cases

  • Participants
  • Parent commits bf62d38
  • Branches bloodhound_rpc

Comments (0)

Files changed (1)

File trunk/tracrpc/tests/json_rpc.py

View file
 from tracrpc.json_rpc import json
 from tracrpc.util import StringIO
 
-from tracrpc.tests import rpc_testenv, TracRpcTestCase
+from tracrpc.tests import TracRpcTestCase
 
 class JsonModuleAvailabilityTestCase(TracRpcTestCase):
 
     class JsonTestCase(TracRpcTestCase):
 
         def _anon_req(self, data):
-            req = urllib2.Request(rpc_testenv.url_anon,
+            req = urllib2.Request(self._testenv.url_anon,
                         headers={'Content-Type': 'application/json'})
             req.data = json.dumps(data)
             resp = urllib2.urlopen(req)
             password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
             handler = urllib2.HTTPBasicAuthHandler(password_mgr)
             password_mgr.add_password(realm=None,
-                          uri=rpc_testenv.url_auth,
+                          uri=self._testenv.url_auth,
                           user=user,
                           passwd=user)
-            req = urllib2.Request(rpc_testenv.url_auth,
+            req = urllib2.Request(self._testenv.url_auth,
                         headers={'Content-Type': 'application/json'})
             req.data = json.dumps(data)
             resp = urllib2.build_opener(handler).open(req)
 
         def test_binary(self):
             # read and write binaries values
-            image_url = os.path.join(rpc_testenv.trac_src, 'trac',
+            image_url = os.path.join(self._testenv.trac_src, 'trac',
                                  'htdocs', 'feed.png')
             image_in = StringIO(open(image_url, 'r').read())
             data = {'method': 'wiki.putAttachmentEx',
 
         def test_xmlrpc_permission(self):
             # Test returned response if not XML_RPC permission
-            rpc_testenv._tracadmin('permission', 'remove', 'anonymous',
+            self._testenv._tracadmin('permission', 'remove', 'anonymous',
                                     'XML_RPC', wait=True)
             try:
                 result = self._anon_req({'method': 'system.listMethods',
                 self.assertTrue('XML_RPC' in result['error']['message'])
             finally:
                 # Add back the default permission for further tests
-                rpc_testenv._tracadmin('permission', 'add', 'anonymous',
+                self._testenv._tracadmin('permission', 'add', 'anonymous',
                                             'XML_RPC', wait=True)
 
         def test_method_not_found(self):
             self.assertEquals(result['error']['message'],
                      'Wiki page "Test" does not exist at version 10')
 
-def test_suite():
-    test_suite = unittest.TestSuite()
-    test_suite.addTest(unittest.makeSuite(JsonModuleAvailabilityTestCase))
-    test_suite.addTest(unittest.makeSuite(JsonTestCase))
-    return test_suite
+def test_suite(suite=None):
+    if suite is None:
+        from tracrpc.tests import functionalSuite
+        suite = functionalSuite()
+    # FIXME: Improve
+    for ts in [unittest.makeSuite(JsonModuleAvailabilityTestCase),
+               unittest.makeSuite(JsonTestCase)]:
+        for test in ts._tests:
+            suite.addTest(test)
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')