Commits

Olemis Lang committed 26e4ed7

Bloodhound RPC : RpcWikiTestCase.test_getPageHTMLWithManipulator ... [ok]

Improved code in testing infrastructure to enable RPC components in global and product context

  • Participants
  • Parent commits 21967be

Comments (0)

Files changed (2)

File trunk/tracrpc/tests/__init__.py

 
             return ProductEnvironment(env, DEFAULT_PRODUCT)
 
+        def get_enabled_components(self):
+            """Also enable built-in RPC components. 
+            """
+            return super(RpcTestEnvironment, self).get_enabled_components() + \
+                    ['tracrpc.*']
+
         def post_create(self, env):
             self.global_env = global_env = env
             self.env = env = self._bloodhound_install(global_env)
             default_product = urllib.quote_plus(DEFAULT_PRODUCT)
 
             print "Enabling RPC plugin and permissions..."
-            global_env.config.set('components', 'tracrpc.*', 'enabled')
-            global_env.config.save()
+            # Not needed anymore , see `get_enabled_components` above
+            #
+            #global_env.config.set('components', 'tracrpc.*', 'enabled')
+            #global_env.config.save()
             
-            env.config.set('components', 'tracrpc.*', 'enabled')
+            # Enable components in product environment
+            for component in self.get_enabled_components():
+                env.config.set('components', component, 'enabled')
             env.config.save()
 
             self.getLogger = lambda : env.log
             if do_wait: # Delay to ensure command executes and caches resets
                 time.sleep(5)
 
+        def restart(self):
+            """Restarts the webserver"""
+            self.stop()
+            self.start()
+
+            # Reload components e.g. those in /plugins folder
+            from trac.loader import load_components
+            plugins_dir = self.global_env.shared_plugins_dir
+            load_components(self.global_env, plugins_dir and (plugins_dir,))
+
+
     rpc_testenv = RpcTestEnvironment(os.path.realpath(os.path.join(
                 os.path.realpath(__file__), '..', '..', '..', 'rpctestenv')),
                 '8765', 'http://127.0.0.1')

File trunk/tracrpc/tests/wiki.py

 import os
 import time
 
+from trac.core import ExtensionPoint
 from trac.util.compat import sorted
+from trac.wiki.api import IWikiPageManipulator
 
 from tracrpc.tests import rpc_testenv, TracRpcTestCase
 from tracrpc.util import StringIO
         "        fields['text'] = 'foo bar baz'\n"
         "    def validate_wiki_page(req, page):\n"
         "        return []\n")
+
+        # Enable manipulator component by hand in product environment
+        rpc_testenv.env.config.set('components', 'Manipulator.WikiManipulator',
+                                   'enabled')
+
+        # Now restart test server
         rpc_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) ), 
+                        "Test wiki manipulator not active in product scope")
+
         # Perform tests
         self.assertEquals('<html><body><p>\nfoo bar baz\n</p>\n</body></html>',
                           self.admin.wiki.getPageHTML('FooBar'))