本文整理匯總了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))