incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1446061 - in /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct: multiproduct/api.py multiproduct/env.py tests/ticket/batch.py
Date Thu, 14 Feb 2013 08:21:38 GMT
Author: jure
Date: Thu Feb 14 08:21:37 2013
New Revision: 1446061

URL: http://svn.apache.org/r1446061
Log:
#355, test cases for batch ticket updates, patch t355_r1444754_trac_test_ticket_batch.patch
applied (from Olemis)


Added:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/batch.py
Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py?rev=1446061&r1=1446060&r2=1446061&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
Thu Feb 14 08:21:37 2013
@@ -24,7 +24,7 @@ from genshi.builder import tag
 import copy
 
 from pkg_resources import resource_filename
-from trac.config import PathOption
+from trac.config import Option, PathOption
 from trac.core import Component, TracError, implements
 from trac.db import Table, Column, DatabaseManager, Index
 from trac.env import IEnvironmentSetupParticipant
@@ -46,6 +46,19 @@ class MultiProductSystem(Component):
     implements(IEnvironmentSetupParticipant, ITemplateProvider,
             IPermissionRequestor, ITicketFieldProvider, IResourceManager)
 
+    product_base_url = Option('multiproduct', 'product_base_url', '',
+        """A pattern used to generate the base URL of product environments,
+        e.g. the use cases listed in bh:wiki:/Proposals/BEP-0003#url-mapping .
+        Both absolute as well as relative URLs are supported. The later 
+        will be resolved with respect to the base URL of the parent global
+        environment. The pattern may contain references to $(prefix)s and 
+        $(name)s placeholders representing the product prefix and name
+        respectively . If nothing is set the following will be used 
+        `products/$(prefix)s`
+
+        Note the usage of `$(...)s` instead of `%(...)s` as the later form 
+        would be interpreted by the ConfigParser itself. """)
+
     product_config_parent = PathOption('inherit', 'multiproduct', '',
         """The path to the configuration file containing the settings shared
         by sibling product environments. By default will inherit 

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=1446061&r1=1446060&r2=1446061&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
Thu Feb 14 08:21:37 2013
@@ -22,7 +22,7 @@ import os.path
 from urlparse import urlsplit
 from sqlite3 import OperationalError
 
-from trac.config import ConfigSection, Option
+from trac.config import BoolOption, ConfigSection, Option
 from trac.core import Component, ComponentManager, implements
 from trac.db.api import TransactionContextManager, QueryContextManager
 from trac.util import get_pkginfo, lazy
@@ -240,11 +240,25 @@ class ProductEnvironment(Component, Comp
         """
         return ''
 
-    # TODO: Estimate product base URL considering global base URL, pattern, ...
-    base_url = ''
-
-    # TODO: Estimate product base URL considering global base URL, pattern, ...
-    base_url_for_redirect = ''
+    base_url = Option('trac', 'base_url', '',
+        """Reference URL for the Trac deployment.
+        
+        This is the base URL that will be used when producing
+        documents that will be used outside of the web browsing
+        context, like for example when inserting URLs pointing to Trac
+        resources in notification e-mails.""")
+
+    base_url_for_redirect = BoolOption('trac', 'use_base_url_for_redirect',
+            False, 
+        """Optionally use `[trac] base_url` for redirects.
+        
+        In some configurations, usually involving running Trac behind
+        a HTTP proxy, Trac can't automatically reconstruct the URL
+        that is used to access it. You may need to use this option to
+        force Trac to use the `base_url` setting also for
+        redirects. This introduces the obvious limitation that this
+        environment will only be usable when accessible from that URL,
+        as redirects are frequently used. ''(since 0.10.5)''""")
 
     @property
     def project_name(self):
@@ -590,9 +604,16 @@ class ProductEnvironment(Component, Comp
         """The application URL"""
         if not self._abs_href:
             if not self.base_url:
-                self.log.warn("base_url option not set in configuration, "
-                              "generated links may be incorrect")
-                self._abs_href = Href('')
+                urlpattern = MultiProductSystem(self.parent).product_base_url
+                if not urlpattern:
+                    self.log.warn("product_base_url option not set in "
+                                  "configuration, generated links may be "
+                                  "incorrect")
+                    urlpattern = 'product/$(prefix)s'
+                url = urlpattern.replace('$(', '%(') \
+                     .replace('%(prefix)s', self.product.prefix) \
+                     .replace('%(name)s', self.product.name)
+                self._abs_href = Href(self.parent.abs_href(url))
             else:
                 self._abs_href = Href(self.base_url)
         return self._abs_href

Added: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/batch.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/batch.py?rev=1446061&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/batch.py
(added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/batch.py
Thu Feb 14 08:21:37 2013
@@ -0,0 +1,66 @@
+
+#  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 Apache(TM) Bloodhound's tickets batch updates 
+in product environments"""
+
+import unittest
+
+from trac.perm import PermissionCache
+from trac.test import Mock
+from trac.ticket.batch import BatchModifyModule
+from trac.ticket.tests.batch import BatchModifyTestCase
+from trac.ticket.default_workflow import ConfigurableTicketWorkflow
+from trac.util.datefmt import utc
+
+from multiproduct.env import ProductEnvironment
+from multiproduct.ticket.web_ui import ProductTicketModule
+from tests.env import MultiproductTestCase
+
+class ProductBatchModifyTestCase(BatchModifyTestCase, MultiproductTestCase):
+
+    def setUp(self):
+        self.global_env = self._setup_test_env(create_folder=False)
+        self._upgrade_mp(self.global_env)
+        self._setup_test_log(self.global_env)
+        self._load_product_from_data(self.global_env, self.default_product)
+        self.env = ProductEnvironment(self.global_env, self.default_product)
+
+        self.global_env.enable_component_in_config(self.env, 
+                ConfigurableTicketWorkflow)
+        self.global_env.enable_component_in_config(self.env, 
+                ProductTicketModule)
+
+        self._load_default_data(self.env)
+
+        self.req = Mock(href=self.env.href, authname='anonymous', tz=utc)
+        self.req.session = {}
+        self.req.perm = PermissionCache(self.env)
+
+    def tearDown(self):
+        self.global_env.reset_db()
+
+
+def test_suite():
+    return unittest.TestSuite([
+            unittest.makeSuite(ProductBatchModifyTestCase,'test'),
+        ])
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+



Mime
View raw message