Commits

Olemis Lang committed 249351c

BH Multiproduct #350 : First draft of test cases towards component status

Comments (0)

Files changed (2)

+t350/t350_r1432088_product_component_enable.diff

t350/t350_r1432088_product_component_enable.diff

+# HG changeset patch
+# Parent 3fc853d53fd5cd35add505162d5da3ac849caa3b
+BH Multiproduct #350 : Product-specific component rules (enable / disable)
+
+diff -r 3fc853d53fd5 bloodhound_multiproduct/tests/env.py
+--- a/bloodhound_multiproduct/tests/env.py	Fri Jan 11 15:17:56 2013 +0000
++++ b/bloodhound_multiproduct/tests/env.py	Sun Jan 13 00:57:47 2013 -0500
+@@ -20,9 +20,15 @@
+ 
+ import os.path
+ import shutil
++from sys import version_info
+ import tempfile
+-import unittest
+ 
++if version_info < (2, 7):
++    import unittest2 as unittest
++else:
++    import unittest
++
++from trac.core import Component
+ from trac.test import EnvironmentStub
+ from trac.tests.env import EnvironmentTestCase
+ 
+@@ -100,6 +106,14 @@
+             # table remains but database version is deleted
+             pass
+ 
++    def _mp_setup(self):
++        """Shortcut for quick product-aware environment setup.
++        """
++        self.env = self._setup_test_env()
++        self._upgrade_mp(self.env)
++        self._setup_test_log(self.env)
++        self._load_product_from_data(self.env, self.default_product)
++
+ class ProductEnvTestCase(EnvironmentTestCase, MultiproductTestCase):
+     r"""Test cases for Trac environments rewritten for product environments
+     """
+@@ -131,8 +145,40 @@
+ 
+         EnvironmentTestCase.tearDown(self)
+ 
++class ProductEnvApiTestCase(MultiproductTestCase):
++    """Assertions for Apache(TM) Bloodhound product-specific extensions in
++    [https://issues.apache.org/bloodhound/wiki/Proposals/BEP-0003 BEP 3]
++    """
++    def setUp(self):
++        self._mp_setup()
++
++    def test_component_enable(self):
++        class C(Component):
++            pass
++        # Let's pretend this was declared elsewhere
++        C.__module__ = 'dummy_module'
++
++        product_env = ProductEnvironment(self.env, self.default_product)
++
++        # C initially disabled in both envs
++        self.assertIs(self.env[C], None)
++        self.assertIs(product_env[C], None)
++
++        # C enabled in product env but not in global env
++        product_env.enable_component(C)
++        self.assertIsNot(self.env[C], None)
++        self.assertIs(product_env[C], None)
++
++        # C enabled in both envs
++        env.enable_component(C)
++        self.assertIsNot(self.env[C], None)
++        self.assertIsNot(product_env[C], None)
++
+ def suite():
+-    return unittest.makeSuite(ProductEnvTestCase,'test')
++    return unittest.TestSuite([
++            unittest.makeSuite(ProductEnvTestCase,'test'),
++            unittest.makeSuite(ProductEnvApiTestCase, 'test')
++        ])
+ 
+ if __name__ == '__main__':
+     unittest.main(defaultTest='suite')
+diff -r 3fc853d53fd5 bloodhound_theme/setup.py
+--- a/bloodhound_theme/setup.py	Fri Jan 11 15:17:56 2013 +0000
++++ b/bloodhound_theme/setup.py	Sun Jan 13 00:57:47 2013 -0500
+@@ -19,6 +19,7 @@
+ #  under the License.
+ 
+ from setuptools import setup
++from sys import version_info
+ 
+ setup(
+   name = 'BloodhoundTheme',
+@@ -33,7 +34,9 @@
+   classifiers = [
+       'Framework :: Trac',
+     ],
+-  install_requires = ['BloodhoundDashboardPlugin', 'TracThemeEngine', 'Trac'],
++  install_requires = ['BloodhoundDashboardPlugin', 'TracThemeEngine', 'Trac',
++          'sqlparse'],
++  tests_require = ['unittest2'] if version_info < (2, 7) else [],
+   entry_points = {
+       'trac.plugins': [
+             'bhtheme.theme = bhtheme.theme',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.