1. Olemis Lang
  2. bloodhound-rpc

Commits

Olemis Lang  committed 9d82f54

BH RPC : Upgrade wiki test cases to work with functional testers and RPC URL

  • Participants
  • Parent commits 5012dfe
  • Branches bloodhound_rpc

Comments (0)

Files changed (1)

File trunk/tracrpc/tests/wiki.py

View file
 from trac.util.compat import sorted
 from trac.wiki.api import IWikiPageManipulator
 
-from tracrpc.tests import rpc_testenv, TracRpcTestCase
+from tracrpc.tests import TracRpcTestCase
 from tracrpc.util import StringIO
 
 class RpcWikiTestCase(TracRpcTestCase):
     
     def setUp(self):
         TracRpcTestCase.setUp(self)
-        self.anon = xmlrpclib.ServerProxy(rpc_testenv.url_anon)
-        self.user = xmlrpclib.ServerProxy(rpc_testenv.url_user)
-        self.admin = xmlrpclib.ServerProxy(rpc_testenv.url_admin)
+        self.anon = self._tester.server_proxy(self.url_anon)
+        self.user = self._tester.server_proxy(self.url_auth, user='user')
+        self.admin = self._tester.server_proxy(self.url_auth, user='admin')
 
     def tearDown(self):
         TracRpcTestCase.tearDown(self)
 
     def test_attachments(self):
         # Note: Quite similar to the tracrpc.tests.json.JsonTestCase.test_binary
-        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())
         # Create attachment
         self.admin.wiki.putPage('ImageTest',
                         '[[Image(wiki:ImageTest:feed.png, nolink)]]\n', {})
         # Create attachment
-        image_url = os.path.join(rpc_testenv.trac_src, 'trac',
+        image_url = os.path.join(self._testenv.trac_src, 'trac',
                              'htdocs', 'feed.png')
         self.admin.wiki.putAttachmentEx('ImageTest', 'feed.png', 'test image',
             xmlrpclib.Binary(open(image_url, 'r').read()))
     def test_getPageHTMLWithManipulator(self):
         self.admin.wiki.putPage('FooBar', 'foo bar', {})
         # Enable wiki manipulator
-        plugin = os.path.join(rpc_testenv.tracdir, 'plugins', 'Manipulator.py')
+        plugin = os.path.join(self._testenv.tracdir, 'plugins', 'Manipulator.py')
         open(plugin, 'w').write(
         "from trac.core import *\n"
         "from trac.wiki.api import IWikiPageManipulator\n"
         "        return []\n")
 
         # Enable manipulator component by hand in product environment
-        rpc_testenv.env.config.set('components', 'Manipulator.WikiManipulator',
+        self._testenv.env.config.set('components', 'Manipulator.WikiManipulator',
                                    'enabled')
 
         # Now restart test server
-        rpc_testenv.restart()
+        self._testenv.restart()
 
         # Check that wiki manipulator component is enabled
         xp = ExtensionPoint(IWikiPageManipulator)
         self.assertTrue(any( c.__class__.__name__ == 'WikiManipulator' 
-                            for c in xp.extensions(rpc_testenv.env) ), 
+                            for c in xp.extensions(self._testenv.env) ), 
                         "Test wiki manipulator not active in product scope")
 
         # Perform tests
                           self.admin.wiki.getPageHTML('FooBar'))
         # Remove plugin and restart
         os.unlink(plugin)
-        rpc_testenv.restart()
+        self._testenv.restart()
 
-def test_suite():
-    return unittest.makeSuite(RpcWikiTestCase)
+def test_suite(suite=None):
+    if suite is None:
+        from tracrpc.tests import functionalSuite
+        suite = functionalSuite()
+    # FIXME: Improve
+    ts = unittest.makeSuite(RpcWikiTestCase)
+    for test in ts._tests:
+        suite.addTest(test)
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')