You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by ju...@apache.org on 2013/02/22 15:03:57 UTC

svn commit: r1449047 - in /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct: multiproduct/env.py tests/wiki/macros.py

Author: jure
Date: Fri Feb 22 14:03:57 2013
New Revision: 1449047

URL: http://svn.apache.org/r1449047
Log:
#355, wiki macros test cases, patch t355_r1446579_trac_test_wiki_macros.diff applied (from Olemis)


Added:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/macros.py
Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py?rev=1449047&r1=1449046&r2=1449047&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py Fri Feb 22 14:03:57 2013
@@ -193,6 +193,14 @@ class ProductEnvironment(Component, Comp
 
     implements(trac.env.ISystemInfoProvider)
 
+    def __getitem__(self, cls):
+        if issubclass(cls, trac.env.Environment):
+            return self.parent
+        elif cls is self.__class__:
+            return self
+        else:
+            return ComponentManager.__getitem__(self, cls)
+
     def __getattr__(self, attrnm):
         """Forward attribute access request to parent environment.
 
@@ -211,6 +219,11 @@ class ProductEnvironment(Component, Comp
             raise AttributeError("'%s' object has no attribute '%s'" %
                     (self.__class__.__name__, attrnm))
 
+    def __repr__(self):
+        return "<%s %s at %s>" % (self.__class__.__name__, 
+                                 repr(self.product.prefix),
+                                 hex(id(self)))
+
     @lazy
     def path(self):
         """The subfolder `./products/<product prefix>` relative to the 
@@ -394,7 +407,14 @@ class ProductEnvironment(Component, Comp
         `None`, the component only gets activated if it is located in
         the `plugins` directory of the environment.
         """
-        if self.parent[cls] is None:
+        if cls is self.__class__:
+            # Prevent lookups in parent env ... will always fail 
+            return True
+        # FIXME : Maybe checking for ComponentManager is too drastic 
+        elif issubclass(cls, ComponentManager):
+            # Avoid clashes with overridden Environment's options 
+            return False
+        elif self.parent[cls] is None:
             return False
         return self.is_component_enabled_local(cls)
 

Added: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/macros.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/macros.py?rev=1449047&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/macros.py (added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/macros.py Fri Feb 22 14:03:57 2013
@@ -0,0 +1,75 @@
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+"""Tests for inherited Apache(TM) Bloodhound's wiki macros 
+in product environments"""
+
+import os.path
+import re
+import unittest
+
+from trac.wiki.tests import macros
+
+from multiproduct.env import ProductEnvironment
+from tests.env import MultiproductTestCase
+from tests.wiki import formatter
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(formatter.test_suite(
+                                  macros.IMAGE_MACRO_TEST_CASES, 
+                                  file=macros.__file__))
+    suite.addTest(formatter.test_suite(
+                                  macros.TITLEINDEX1_MACRO_TEST_CASES, 
+                                  file=macros.__file__))
+    suite.addTest(formatter.test_suite(
+                                  macros.TITLEINDEX2_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.titleindex2_setup,
+                                  teardown=macros.titleindex_teardown))
+    suite.addTest(formatter.test_suite(
+                                  macros.TITLEINDEX3_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.titleindex3_setup,
+                                  teardown=macros.titleindex_teardown))
+    suite.addTest(formatter.test_suite(
+                                  macros.TITLEINDEX4_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.titleindex4_setup,
+                                  teardown=macros.titleindex_teardown))
+    suite.addTest(formatter.test_suite(
+                                  macros.TITLEINDEX5_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.titleindex5_setup,
+                                  teardown=macros.titleindex_teardown))
+    suite.addTest(formatter.test_suite(
+                                  macros.RECENTCHANGES_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.recentchanges_setup,
+                                  teardown=macros.recentchanges_teardown))
+    suite.addTest(formatter.test_suite(
+                                  macros.TRACINI_MACRO_TEST_CASES, 
+                                  file=macros.__file__,
+                                  setup=macros.tracini_setup,
+                                  teardown=macros.tracini_teardown))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+