本文整理汇总了Python中bitten.model.TargetPlatform类的典型用法代码示例。如果您正苦于以下问题:Python TargetPlatform类的具体用法?Python TargetPlatform怎么用?Python TargetPlatform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TargetPlatform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_view_config_paging
def test_view_config_paging(self):
config = BuildConfig(self.env, name='test', path='trunk')
config.insert()
platform = TargetPlatform(self.env, config='test', name='any')
platform.insert()
PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW')
req = Mock(method='GET', base_path='', cgi_location='',
path_info='/build/test', href=Href('/trac'), args={},
chrome={}, authname='joe',
perm=PermissionCache(self.env, 'joe'))
root = Mock(get_entries=lambda: ['foo'],
get_history=lambda: [('trunk', rev, 'edit') for rev in
range(123, 110, -1)])
self.repos = Mock(get_node=lambda path, rev=None: root,
sync=lambda: None, normalize_path=lambda path: path)
self.repos.authz = Mock(has_permission=lambda path: True, assert_permission=lambda path: None)
module = BuildConfigController(self.env)
assert module.match_request(req)
_, data, _ = module.process_request(req)
if req.chrome:
self.assertEqual('/trac/build/test?page=2',
req.chrome['links']['next'][0]['href'])
示例2: test_view_config
def test_view_config(self):
config = BuildConfig(self.env, name='test', path='trunk')
config.insert()
platform = TargetPlatform(self.env, config='test', name='any')
platform.insert()
PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW')
req = Mock(method='GET', base_path='', cgi_location='',
path_info='/build/test', href=Href('/trac'), args={},
chrome={}, authname='joe',
perm=PermissionCache(self.env, 'joe'))
root = Mock(get_entries=lambda: ['foo'],
get_history=lambda: [('trunk', rev, 'edit') for rev in
range(123, 111, -1)])
self.repos.get_node=lambda path, rev=None: root
self.repos.youngest_rev=123
self.repos.get_changeset=lambda rev: Mock(author='joe', date=99)
module = BuildConfigController(self.env)
assert module.match_request(req)
_, data, _ = module.process_request(req)
self.assertEqual('view_config', data['page_mode'])
assert not 'next' in req.chrome['links']
self.assertEquals(Resource('build', 'test'), data['context'].resource)
self.assertEquals([], data['config']['attachments']['attachments'])
self.assertEquals('/trac/attachment/build/test/',
data['config']['attachments']['attach_href'])
示例3: should_delete_build
def should_delete_build(self, build, repos):
# Ignore pending builds for deactived build configs
config = BuildConfig.fetch(self.env, build.config)
if not config.active:
target_platform = TargetPlatform.fetch(self.env, build.platform)
if target_platform:
target_platform_name = '"%s"' % (target_platform.name,)
else:
target_platform_name = 'unknown platform "%s"' % (build.platform,)
log.info('Dropping build of configuration "%s" at '
'revision [%s] on %s because the configuration is '
'deactivated', config.name, build.rev,
target_platform_name)
return True
# Stay within the revision limits of the build config
if (config.min_rev and repos.rev_older_than(build.rev,
config.min_rev)) \
or (config.max_rev and repos.rev_older_than(config.max_rev,
build.rev)):
# This minimum and/or maximum revision has changed since
# this build was enqueued, so drop it
log.info('Dropping build of configuration "%s" at revision [%s] on '
'"%s" because it is outside of the revision range of the '
'configuration', config.name, build.rev,
TargetPlatform.fetch(self.env, build.platform).name)
return True
return False
示例4: test_process_remove_platforms
def test_process_remove_platforms(self):
BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
active=True).insert()
platform = TargetPlatform(self.env, config='foo', name='any')
platform.insert()
redirected_to = []
def redirect(url):
redirected_to.append(url)
raise RequestDone
req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
abs_href=Href('http://example.org/'), redirect=redirect,
authname='joe', chrome={'warnings': [], 'notices': []},
href=Href('/'),
args={'remove': '', 'sel': str(platform.id)})
provider = BuildConfigurationsAdminPageProvider(self.env)
try:
provider.render_admin_panel(req, 'bitten', 'configs', 'foo')
self.fail('Expected RequestDone')
except RequestDone:
self.assertEquals(['Target Platform(s) Removed.'],
req.chrome['notices'])
self.assertEqual('http://example.org/admin/bitten/configs/foo',
redirected_to[0])
platforms = list(TargetPlatform.select(self.env, config='foo'))
self.assertEqual(0, len(platforms))
示例5: test_process_update_platform_cancel
def test_process_update_platform_cancel(self):
BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
active=True).insert()
platform = TargetPlatform(self.env, config='foo', name='any')
platform.insert()
redirected_to = []
def redirect(url):
redirected_to.append(url)
raise RequestDone
req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
abs_href=Href('http://example.org/'), redirect=redirect,
authname='joe',
args={'cancel': '', 'edit': '', 'name': 'Changed',
'property_0': 'family', 'pattern_0': 'posix'})
provider = BuildConfigurationsAdminPageProvider(self.env)
try:
provider.render_admin_panel(req, 'bitten', 'configs',
'foo/%d' % platform.id)
self.fail('Expected RequestDone')
except RequestDone:
self.assertEqual('http://example.org/admin/bitten/configs/foo',
redirected_to[0])
platforms = list(TargetPlatform.select(self.env, config='foo'))
self.assertEqual(1, len(platforms))
self.assertEqual('any', platforms[0].name)
self.assertEqual([], platforms[0].rules)
示例6: test_bitten_keeps_order_of_revisions_from_versioncontrol
def test_bitten_keeps_order_of_revisions_from_versioncontrol(self):
# Trac's API specifies that they are sorted chronological (backwards)
# We must not assume that these revision numbers can be sorted later on,
# for example the mercurial plugin will return the revisions as strings
# (e.g. '880:4c19fa95fb9e')
config = BuildConfig(self.env, name='test', path='trunk')
config.insert()
platform = TargetPlatform(self.env, config='test', name='any')
platform.insert()
PermissionSystem(self.env).grant_permission('joe', 'BUILD_VIEW')
req = Mock(method='GET', base_path='', cgi_location='',
path_info='/build/'+config.name, href=Href('/trac'), args={},
chrome={}, authname='joe',
perm=PermissionCache(self.env, 'joe'))
# revisions are intentionally not sorted in any way - bitten should just keep them!
revision_ids = [5, 8, 2]
revision_list = [('trunk', revision, 'edit') for revision in revision_ids]
root = Mock(get_entries=lambda: ['foo'], get_history=lambda: revision_list)
self.repos.get_node=lambda path, rev=None: root
self.repos.youngest_rev=5
self.repos.get_changeset=lambda rev: Mock(author='joe', date=99)
module = BuildConfigController(self.env)
assert module.match_request(req)
_, data, _ = module.process_request(req)
actual_revision_ids = data['config']['revisions']
self.assertEquals(revision_ids, actual_revision_ids)
示例7: test_register_slave_match_simple_fail
def test_register_slave_match_simple_fail(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('family', 'posix'))
platform.insert()
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'family': 'nt'})
self.assertEqual([], platforms)
示例8: test_register_slave_match_regexp_invalid
def test_register_slave_match_regexp_invalid(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('version', '8(\.\d'))
platform.insert()
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'version': '7.8.1'})
self.assertEqual([], platforms)
示例9: _create_platform
def _create_platform(self, req, config_name):
req.perm.assert_permission('BUILD_MODIFY')
name = req.args.get('platform_name')
if not name:
raise TracError('Missing required field "name"', 'Missing field')
platform = TargetPlatform(self.env, config=config_name, name=name)
platform.insert()
return platform
示例10: test_register_slave_match_regexp
def test_register_slave_match_regexp(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('version', '8\.\d\.\d'))
platform.insert()
platform_id = platform.id
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'version': '8.2.0'})
self.assertEqual(1, len(platforms))
self.assertEqual(platform_id, platforms[0].id)
示例11: test_register_slave_match_case_insensitive
def test_register_slave_match_case_insensitive(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('os', 'LiNUX'))
platform.insert()
platform_id = platform.id
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'os': 'linux'})
self.assertEqual(1, len(platforms))
self.assertEqual(platform_id, platforms[0].id)
示例12: test_match_slave_match
def test_match_slave_match(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('family', 'posix'))
platform.insert()
platform_id = platform.id
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'family': 'posix'})
self.assertEqual(1, len(platforms))
self.assertEqual(platform_id, platforms[0].id)
示例13: test_delete_platform_with_pending_builds
def test_delete_platform_with_pending_builds(self):
"""Check that deleting a platform with pending builds removes those pending builds"""
db = self.env.get_db_cnx()
platform = TargetPlatform(self.env, config='test', name='Linux')
platform.insert()
build = Build(self.env, config='test', platform=platform.id, rev='42', rev_time=12039)
build.insert()
platform.delete()
pending = list(build.select(self.env, config='test', status=Build.PENDING))
self.assertEqual(0, len(pending))
示例14: test_register_slave_match_regexp_multi
def test_register_slave_match_regexp_multi(self):
BuildConfig(self.env, 'test', active=True).insert()
platform = TargetPlatform(self.env, config='test', name="Unix")
platform.rules.append(('os', '^Linux'))
platform.rules.append(('processor', '^[xi]\d?86$'))
platform.insert()
platform_id = platform.id
queue = BuildQueue(self.env)
platforms = queue.match_slave('foo', {'os': 'Linux', 'processor': 'i686'})
self.assertEqual(1, len(platforms))
self.assertEqual(platform_id, platforms[0].id)
示例15: test_should_delete_build_config_none
def test_should_delete_build_config_none(self):
out = []
self.env.log = Mock(
info=lambda msg, *args: out.extend([msg] + list(args)))
platform = TargetPlatform(self.env, config='test', name='stuff')
platform.insert()
build = Build(self.env, config='does_not_exist', rev=42,
platform=platform.id, rev_time=123456)
build.insert()
queue = BuildQueue(self.env, build_all=True)
self.assertEqual(True, queue.should_delete_build(build, self.repos))
self.assertTrue("configuration is deactivated" in out[0])
self.assertEquals('unknown config "does_not_exist"', out[1])