本文整理汇总了Python中trac.db.api.DatabaseManager.set_database_version方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.set_database_version方法的具体用法?Python DatabaseManager.set_database_version怎么用?Python DatabaseManager.set_database_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.db.api.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.set_database_version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade_environment
# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import set_database_version [as 别名]
def upgrade_environment(self):
"""
Actually perform an environment upgrade, but don't commit as
that is done by the common upgrade procedure when all plugins are done.
"""
dbm = DatabaseManager(self.env)
current_ver = dbm.get_database_version(db_version_key)
if current_ver == 0:
dbm.create_tables(schema.values())
else:
while current_ver + 1 <= db_version:
upgrade_map[current_ver + 1](self.env)
current_ver += 1
dbm.set_database_version(db_version, db_version_key)
示例2: DatabaseManagerTestCase
# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import set_database_version [as 别名]
class DatabaseManagerTestCase(unittest.TestCase):
def setUp(self):
self.env = EnvironmentStub(default_data=True)
self.dbm = DatabaseManager(self.env)
def tearDown(self):
self.env.reset_db()
def test_get_default_database_version(self):
"""Get database version for the default entry named
`database_version`.
"""
self.assertEqual(default_db_version, self.dbm.get_database_version())
def test_get_table_names(self):
"""Get table names for the default database."""
self.assertEqual(sorted(table.name for table in default_schema),
sorted(self.dbm.get_table_names()))
def test_set_default_database_version(self):
"""Set database version for the default entry named
`database_version`.
"""
new_db_version = default_db_version + 1
self.dbm.set_database_version(new_db_version)
self.assertEqual(new_db_version, self.dbm.get_database_version())
# Restore the previous version to avoid destroying the database
# on teardown
self.dbm.set_database_version(default_db_version)
self.assertEqual(default_db_version, self.dbm.get_database_version())
def test_set_get_plugin_database_version(self):
"""Get and set database version for an entry with an
arbitrary name.
"""
name = 'a_trac_plugin_version'
db_ver = 1
self.assertFalse(self.dbm.get_database_version(name))
self.dbm.set_database_version(db_ver, name)
self.assertEqual(db_ver, self.dbm.get_database_version(name))