Source

bloodhound-mq / t350 / t350_r1432088_product_component_enable.diff

Full commit
# HG changeset patch
# Parent 0ce445d6efc5f22823d02def8b5988e90d145246
BH Multiproduct #350 : Product-specific component rules (enable / disable)

diff -r 0ce445d6efc5 bloodhound_multiproduct/tests/env.py
--- a/bloodhound_multiproduct/tests/env.py	Mon Jan 14 19:07:09 2013 -0500
+++ b/bloodhound_multiproduct/tests/env.py	Mon Jan 14 19:19:04 2013 -0500
@@ -228,6 +228,28 @@
         #        "(got multiproduct.env.ProductEnvironment instance instead)"
         #self.assertEqual(msg, expected_msg)
 
+    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 tearDown(self):
         # Release reference to transient environment mock object
         self.env = None