Commits

Olemis Lang committed 91e8451

BH Multiproduct #592 : Product env's abs_href ... TESTED

  • Participants
  • Parent commits 97ac6de
  • Branches t592_base_url

Comments (0)

Files changed (4)

-t592/t592_r_product_base_url.diff
+t592/t592_r1503620_product_base_url.diff
+t592/t592_r1503620_test_product_base_url.diff

File t592/t592_r1503620_product_base_url.diff

+# HG changeset patch
+# Parent 787d3676d94746bd384763f16e1d1bf10cf3f92e
+BH Multiproduct #592 : Do not override product base URL with global env's
+
+diff -r 787d3676d947 bloodhound_multiproduct/multiproduct/env.py
+--- a/bloodhound_multiproduct/multiproduct/env.py	Tue Jul 16 09:00:10 2013 +0000
++++ b/bloodhound_multiproduct/multiproduct/env.py	Tue Jul 16 18:27:21 2013 -0500
+@@ -405,7 +405,7 @@
+         """
+         return ''
+ 
+-    base_url = Option('trac', 'base_url', '',
++    _base_url = Option('trac', 'base_url', '',
+         """Reference URL for the Trac deployment.
+         
+         This is the base URL that will be used when producing
+@@ -413,7 +413,14 @@
+         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',
++    @property
++    def base_url(self):
++        base_url = self._base_url
++        if base_url == self.parent.base_url:
++            return ''
++        return base_url
++
++    _base_url_for_redirect = BoolOption('trac', 'use_base_url_for_redirect',
+             False, 
+         """Optionally use `[trac] base_url` for redirects.
+         

File t592/t592_r1503620_test_product_base_url.diff

+# HG changeset patch
+# Parent 65bf5998d3bffca138ac064455496b35d4f5092c
+BH Multiproduct #592 : Test cases for product base URL config
+
+diff -r 65bf5998d3bf bloodhound_multiproduct/tests/env.py
+--- a/bloodhound_multiproduct/tests/env.py	Tue Jul 16 18:27:21 2013 -0500
++++ b/bloodhound_multiproduct/tests/env.py	Tue Jul 16 18:35:55 2013 -0500
+@@ -42,6 +42,7 @@
+ from trac.ticket.report import ReportModule
+ from trac.ticket.web_ui import TicketModule
+ from trac.util.text import to_unicode
++from trac.web.href import Href
+ 
+ from multiproduct.api import MultiProductSystem
+ from multiproduct.env import ProductEnvironment
+@@ -608,6 +609,42 @@
+         """
+         self.assertEqual('http://env.tld/bh/tp1', self.product_env.abs_href())
+ 
++    @product_base_url('http://$(prefix)s.$(envname)s.tld/')
++    def test_resolve_base_url(self):
++        # Global environment base URL
++        self.env.abs_href = Href('http://globalenv.com')
++        gconfig = self.env.config
++        gconfig.set('trac', 'base_url', 'http://globalenv.com')
++        gconfig.save()
++
++        #Global URLs
++        self.assertEqual('http://globalenv.com', self.env.base_url)
++        self.assertEqual('http://globalenv.com', self.env.abs_href())
++
++        # Product URLs
++        self.product_env._abs_href = None
++        self.assertEqual('', self.product_env.base_url)
++        self.assertEqual('http://tp1.env.tld', self.product_env.abs_href())
++
++        # Product base URL equal to global env URL
++        self.product_env._abs_href = None
++        del self.product_env.abs_href
++        pconfig = self.product_env.config
++        pconfig.set('trac', 'base_url', 'http://globalenv.com')
++        pconfig.save()
++
++        self.assertEqual('', self.product_env.base_url)
++        self.assertEqual('http://tp1.env.tld', self.product_env.abs_href())
++
++        # Product base URL overrides global URL template
++        self.product_env._abs_href = None
++        del self.product_env.abs_href
++        pconfig.set('trac', 'base_url', 'http://productenv.com')
++        pconfig.save()
++
++        self.assertEqual('http://productenv.com', self.product_env.base_url)
++        self.assertEqual('http://productenv.com', self.product_env.abs_href())
++
+     product_base_url = staticmethod(product_base_url)
+ 
+ 

File t592/t592_r_product_base_url.diff

-# HG changeset patch
-# Parent c968b44aa150938d887047c5811e9246e75b943e
-BH Multiproduct #592 : Do not override product base URL with global env's
-
-diff -r c968b44aa150 bloodhound_multiproduct/multiproduct/env.py
---- a/bloodhound_multiproduct/multiproduct/env.py	Wed Jul 10 22:34:15 2013 +0000
-+++ b/bloodhound_multiproduct/multiproduct/env.py	Tue Jul 16 17:32:02 2013 -0500
-@@ -405,7 +405,7 @@
-         """
-         return ''
- 
--    base_url = Option('trac', 'base_url', '',
-+    _base_url = Option('trac', 'base_url', '',
-         """Reference URL for the Trac deployment.
-         
-         This is the base URL that will be used when producing
-@@ -413,7 +413,13 @@
-         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',
-+    @property
-+    def base_url(self):
-+        base_url = self._base_url
-+        if base_url == self.parent.base_url:
-+            return ''
-+
-+    _base_url_for_redirect = BoolOption('trac', 'use_base_url_for_redirect',
-             False, 
-         """Optionally use `[trac] base_url` for redirects.
-