本文整理汇总了Python中trac.env.Environment.abs_href方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.abs_href方法的具体用法?Python Environment.abs_href怎么用?Python Environment.abs_href使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.env.Environment
的用法示例。
在下文中一共展示了Environment.abs_href方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EnvironmentTestCase
# 需要导入模块: from trac.env import Environment [as 别名]
# 或者: from trac.env.Environment import abs_href [as 别名]
class EnvironmentTestCase(unittest.TestCase):
def setUp(self):
env_path = tempfile.mkdtemp(prefix='trac-tempenv-')
self.env = Environment(env_path, create=True)
self.env.config.set('trac', 'base_url',
'http://trac.edgewall.org/some/path')
self.env.config.save()
def tearDown(self):
self.env.shutdown() # really closes the db connections
shutil.rmtree(self.env.path)
def test_abs_href(self):
self.assertEqual('http://trac.edgewall.org/some/path', self.env.abs_href())
def test_href(self):
self.assertEqual('/some/path', self.env.href())
def test_get_version(self):
"""Testing env.get_version"""
self.assertEqual(db_default.db_version, self.env.get_version())
def test_get_known_users(self):
"""Testing env.get_known_users"""
with self.env.db_transaction as db:
db.executemany("INSERT INTO session VALUES (%s,%s,0)",
[('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)])
db.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)",
[('123', 0, 'email', '[email protected]'),
('tom', 1, 'name', 'Tom'),
('tom', 1, 'email', '[email protected]'),
('joe', 1, 'email', '[email protected]'),
('jane', 1, 'name', 'Jane')])
users = {}
for username, name, email in self.env.get_known_users():
users[username] = (name, email)
self.assertTrue('anonymous' not in users)
self.assertEqual(('Tom', '[email protected]'), users['tom'])
self.assertEqual((None, '[email protected]'), users['joe'])
self.assertEqual(('Jane', None), users['jane'])