本文整理汇总了Python中multiproduct.env.ProductEnvironment.href方法的典型用法代码示例。如果您正苦于以下问题:Python ProductEnvironment.href方法的具体用法?Python ProductEnvironment.href怎么用?Python ProductEnvironment.href使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiproduct.env.ProductEnvironment
的用法示例。
在下文中一共展示了ProductEnvironment.href方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProductEnvHrefTestCase
# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import href [as 别名]
class ProductEnvHrefTestCase(MultiproductTestCase):
"""Assertions for resolution of product environment's base URL
[https://issues.apache.org/bloodhound/wiki/Proposals/BEP-0003 BEP 3]
"""
def product_base_url(url_template):
def decorator(f):
f.product_base_url = url_template
return f
return decorator
def setUp(self):
self._mp_setup()
self.env.path = '/path/to/env'
self.env.abs_href = Href('http://globalenv.com/trac.cgi')
url_pattern = getattr(getattr(self, self._testMethodName).im_func,
'product_base_url', '')
self.env.config.set('multiproduct', 'product_base_url', url_pattern)
self.env.config.set('trac', 'base_url', 'http://globalenv.com/trac.cgi')
self.product_env = ProductEnvironment(self.env, self.default_product)
def tearDown(self):
# Release reference to transient environment mock object
if self.env is not None:
try:
self.env.reset_db()
except OperationalError:
# "Database not found ...",
# "OperationalError: no such table: system" or the like
pass
self.env = None
self.product_env = None
@product_base_url('http://$(prefix)s.domain.tld/')
def test_href_subdomain(self):
"""Test product sub domain base URL
"""
self.assertEqual('/', self.product_env.href())
self.assertEqual('http://tp1.domain.tld', self.product_env.abs_href())
@product_base_url('/path/to/bloodhound/$(prefix)s')
def test_href_sibling_paths(self):
"""Test product base URL at sibling paths
"""
self.assertEqual('/trac.cgi/path/to/bloodhound/tp1',
self.product_env.href())
self.assertEqual('http://globalenv.com/trac.cgi/path/to/bloodhound/tp1',
self.product_env.abs_href())
@product_base_url('/$(envname)s/$(prefix)s')
def test_href_inherit_sibling_paths(self):
"""Test product base URL at sibling paths inheriting configuration.
"""
self.assertEqual('/trac.cgi/env/tp1', self.product_env.href())
self.assertEqual('http://globalenv.com/trac.cgi/env/tp1',
self.product_env.abs_href())
@product_base_url('')
def test_href_default(self):
"""Test product base URL is to a default
"""
self.assertEqual('/trac.cgi/products/tp1', self.product_env.href())
self.assertEqual('http://globalenv.com/trac.cgi/products/tp1',
self.product_env.abs_href())
@product_base_url('/products/$(prefix)s')
def test_href_embed(self):
"""Test default product base URL /products/prefix
"""
self.assertEqual('/trac.cgi/products/tp1', self.product_env.href())
self.assertEqual('http://globalenv.com/trac.cgi/products/tp1',
self.product_env.abs_href())
@product_base_url('http://$(envname)s.tld/bh/$(prefix)s')
def test_href_complex(self):
"""Test complex product base URL
"""
self.assertEqual('/bh/tp1', self.product_env.href())
self.assertEqual('http://env.tld/bh/tp1', self.product_env.abs_href())
@product_base_url('http://$(prefix)s.$(envname)s.tld/')
def test_product_href_uses_multiproduct_product_base_url(self):
"""Test that [multiproduct] product_base_url is used to compute
abs_href for the product environment when [trac] base_url for
the product environment is an empty string (the default).
"""
# Global URLs
self.assertEqual('http://globalenv.com/trac.cgi', self.env.base_url)
self.assertEqual('/trac.cgi', self.env.href())
self.assertEqual('http://globalenv.com/trac.cgi', self.env.abs_href())
# Product URLs
self.assertEqual('', self.product_env.base_url)
self.assertEqual('/', self.product_env.href())
self.assertEqual('http://tp1.env.tld', self.product_env.abs_href())
@product_base_url('http://$(prefix)s.$(envname)s.tld/')
def test_product_href_uses_products_base_url(self):
"""Test that [trac] base_url for the product environment is used to
#.........这里部分代码省略.........