本文整理汇总了Python中bitten.model.BuildConfig.update方法的典型用法代码示例。如果您正苦于以下问题:Python BuildConfig.update方法的具体用法?Python BuildConfig.update怎么用?Python BuildConfig.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitten.model.BuildConfig
的用法示例。
在下文中一共展示了BuildConfig.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CollectChangesTestCase
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import update [as 别名]
class CollectChangesTestCase(unittest.TestCase):
"""
Unit tests for the `bitten.queue.collect_changes` function.
"""
def setUp(self):
self.env = EnvironmentStub()
self.env.path = tempfile.mkdtemp()
db = self.env.get_db_cnx()
cursor = db.cursor()
connector, _ = DatabaseManager(self.env)._get_connector()
for table in schema:
for stmt in connector.to_sql(table):
cursor.execute(stmt)
self.config = BuildConfig(self.env, name='test', path='somepath')
self.config.insert(db=db)
self.platform = TargetPlatform(self.env, config='test', name='Foo')
self.platform.insert(db=db)
db.commit()
def tearDown(self):
shutil.rmtree(self.env.path)
def test_stop_on_copy(self):
self.env.get_repository = lambda authname=None: Mock(
get_node=lambda path, rev=None: Mock(
get_history=lambda: [('otherpath', 123, 'copy')]
),
normalize_path=lambda path: path
)
retval = list(collect_changes(self.env.get_repository(), self.config))
self.assertEqual(0, len(retval))
def test_stop_on_minrev(self):
self.env.get_repository = lambda authname=None: Mock(
get_node=lambda path, rev=None: Mock(
get_entries=lambda: [Mock(), Mock()],
get_history=lambda: [('somepath', 123, 'edit'),
('somepath', 121, 'edit'),
('somepath', 120, 'edit')]
),
normalize_path=lambda path: path,
rev_older_than=lambda rev1, rev2: rev1 < rev2
)
self.config.min_rev = 123
self.config.update()
retval = list(collect_changes(self.env.get_repository(), self.config))
self.assertEqual(1, len(retval))
self.assertEqual(123, retval[0][1])
def test_skip_until_maxrev(self):
self.env.get_repository = lambda authname=None: Mock(
get_node=lambda path, rev=None: Mock(
get_entries=lambda: [Mock(), Mock()],
get_history=lambda: [('somepath', 123, 'edit'),
('somepath', 121, 'edit'),
('somepath', 120, 'edit')]
),
normalize_path=lambda path: path,
rev_older_than=lambda rev1, rev2: rev1 < rev2
)
self.config.max_rev=121
self.config.update()
retval = list(collect_changes(self.env.get_repository(), self.config))
self.assertEqual(2, len(retval))
self.assertEqual(121, retval[0][1])
self.assertEqual(120, retval[1][1])
def test_skip_empty_dir(self):
def _mock_get_node(path, rev=None):
if rev and rev == 121:
return Mock(
get_entries=lambda: []
)
else:
return Mock(
get_entries=lambda: [Mock(), Mock()],
get_history=lambda: [('somepath', 123, 'edit'),
('somepath', 121, 'edit'),
('somepath', 120, 'edit')]
)
self.env.get_repository = lambda authname=None: Mock(
get_node=_mock_get_node,
normalize_path=lambda path: path,
rev_older_than=lambda rev1, rev2: rev1 < rev2
)
retval = list(collect_changes(self.env.get_repository(), self.config))
self.assertEqual(2, len(retval))
self.assertEqual(123, retval[0][1])
self.assertEqual(120, retval[1][1])
示例2: CollectChangesTestCase
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import update [as 别名]
class CollectChangesTestCase(unittest.TestCase):
"""
Unit tests for the `bitten.queue.collect_changes` function.
"""
def setUp(self):
self.env = EnvironmentStub(enable=['trac.*', 'bitten.*'])
self.env.path = tempfile.mkdtemp()
db = self.env.get_db_cnx()
cursor = db.cursor()
connector, _ = DatabaseManager(self.env)._get_connector()
for table in schema:
for stmt in connector.to_sql(table):
cursor.execute(stmt)
self.config = BuildConfig(self.env, name='test', path='somepath')
self.config.insert(db=db)
self.platform = TargetPlatform(self.env, config='test', name='Foo')
self.platform.insert(db=db)
db.commit()
# Hook up a dummy repository
self.repos = Mock()
self.env.get_repository = lambda authname=None: self.repos # 0.11
try: # 0.12+
from trac.core import Component, implements
from trac.versioncontrol.api import IRepositoryConnector, \
IRepositoryProvider
class DummyRepos(Component):
implements(IRepositoryConnector, IRepositoryProvider)
def get_supported_types(self):
yield ('dummy', 9)
def get_repository(this, repos_type, repos_dir, params):
return self.repos # Note: 'this' vs 'self' usage
def get_repositories(self):
yield ('', {'dir': 'dummy_dir', 'type': 'dummy'})
self.dummy = DummyRepos
except ImportError:
self.dummy = None # not supported, will use get_repository()
def tearDown(self):
if self.dummy: # remove from components list + interfaces dict
self.env.__metaclass__._components.remove(self.dummy)
for key in self.env.__metaclass__._registry.keys():
if self.dummy in self.env.__metaclass__._registry[key]:
self.env.__metaclass__._registry[key].remove(self.dummy)
shutil.rmtree(self.env.path)
def test_stop_on_copy(self):
self.repos.get_node=lambda path, rev=None: Mock(
get_history=lambda: [('otherpath', 123, 'copy')])
self.repos.normalize_path=lambda path: path
retval = list(collect_changes(self.config))
self.assertEqual(0, len(retval))
def test_stop_on_minrev(self):
self.repos.get_node=lambda path, rev=None: Mock(
get_entries=lambda: [Mock(), Mock()],
get_history=lambda: [('somepath', 123, 'edit'),
('somepath', 121, 'edit'),
('somepath', 120, 'edit')])
self.repos.normalize_path=lambda path: path
self.repos.rev_older_than=lambda rev1, rev2: rev1 < rev2
self.config.min_rev = 123
self.config.update()
retval = list(collect_changes(self.config))
self.assertEqual(1, len(retval))
self.assertEqual(123, retval[0][1])
def test_skip_until_maxrev(self):
self.repos.get_node=lambda path, rev=None: Mock(
get_entries=lambda: [Mock(), Mock()],
get_history=lambda: [('somepath', 123, 'edit'),
('somepath', 121, 'edit'),
('somepath', 120, 'edit')])
self.repos.normalize_path=lambda path: path
self.repos.rev_older_than=lambda rev1, rev2: rev1 < rev2
self.config.max_rev=121
self.config.update()
retval = list(collect_changes(self.config))
self.assertEqual(2, len(retval))
self.assertEqual(121, retval[0][1])
self.assertEqual(120, retval[1][1])
def test_skip_empty_dir(self):
def _mock_get_node(path, rev=None):
if rev and rev == 121:
return Mock(
get_entries=lambda: []
)
else:
return Mock(
get_entries=lambda: [Mock(), Mock()],
#.........这里部分代码省略.........