当前位置: 首页>>代码示例>>Python>>正文


Python admin.BuildConfigurationsAdminPageProvider类代码示例

本文整理汇总了Python中bitten.admin.BuildConfigurationsAdminPageProvider的典型用法代码示例。如果您正苦于以下问题:Python BuildConfigurationsAdminPageProvider类的具体用法?Python BuildConfigurationsAdminPageProvider怎么用?Python BuildConfigurationsAdminPageProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BuildConfigurationsAdminPageProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_process_view_configs

    def test_process_view_configs(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()
        BuildConfig(self.env, name='bar', label='Bar', path='branches/bar',
                    min_rev='123', max_rev='456').insert()

        req = Mock(method='GET', chrome={}, href=Href('/'),
                   perm=PermissionCache(self.env, 'joe'))

        provider = BuildConfigurationsAdminPageProvider(self.env)
        template_name, data = provider.render_admin_panel(
            req, 'bitten', 'configs', ''
        )

        self.assertEqual('bitten_admin_configs.html', template_name)
        assert 'configs' in data
        configs = data['configs']
        self.assertEqual(2, len(configs))
        self.assertEqual({
            'name': 'bar', 'href': '/admin/bitten/configs/bar',
            'label': 'Bar', 'min_rev': '123', 'max_rev': '456',
            'path': 'branches/bar', 'active': False, 'recipe': False
        }, configs[0])
        self.assertEqual({
            'name': 'foo', 'href': '/admin/bitten/configs/foo',
            'label': 'Foo', 'min_rev': None, 'max_rev': None,
            'path': 'branches/foo', 'active': True, 'recipe': False
        }, configs[1])
开发者ID:lkraav,项目名称:trachacks,代码行数:28,代码来源:admin.py

示例2: test_process_update_config

    def test_process_update_config(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).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={'save': '', 'name': 'foo', 'label': 'Foobar',
                         'description': 'Thanks for all the fish!'})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', 'foo')
            self.fail('Expected RequestDone')

        except RequestDone:
            self.assertEqual(['Configuration Saved.'], req.chrome['notices'])
            self.assertEqual('http://example.org/admin/bitten/configs/foo',
                             redirected_to[0])
            config = BuildConfig.fetch(self.env, name='foo')
            self.assertEqual('Foobar', config.label)
            self.assertEqual('Thanks for all the fish!', config.description)
开发者ID:lkraav,项目名称:trachacks,代码行数:27,代码来源:admin.py

示例3: 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)
开发者ID:lkraav,项目名称:trachacks,代码行数:29,代码来源:admin.py

示例4: test_process_deactivate_config

    def test_process_deactivate_config(self):
        BuildConfig(self.env, name='foo', path='branches/foo',
                    active=True).insert()
        BuildConfig(self.env, name='bar', path='branches/bar',
                    active=True).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={'apply': ''})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', '')
            self.fail('Expected RequestDone')

        except RequestDone:
            self.assertEqual('http://example.org/admin/bitten/configs',
                             redirected_to[0])
            config = BuildConfig.fetch(self.env, name='foo')
            self.assertEqual(False, config.active)
            config = BuildConfig.fetch(self.env, name='bar')
            self.assertEqual(False, config.active)
开发者ID:lkraav,项目名称:trachacks,代码行数:27,代码来源:admin.py

示例5: 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))
开发者ID:lkraav,项目名称:trachacks,代码行数:28,代码来源:admin.py

示例6: test_get_admin_panels

    def test_get_admin_panels(self):
        provider = BuildConfigurationsAdminPageProvider(self.env)

        req = Mock(perm=PermissionCache(self.env, 'joe'))
        self.assertEqual([('bitten', 'Builds', 'configs', 'Configurations')],
                         list(provider.get_admin_panels(req)))

        PermissionSystem(self.env).revoke_permission('joe', 'BUILD_MODIFY')
        req = Mock(perm=PermissionCache(self.env, 'joe'))
        self.assertEqual([], list(provider.get_admin_panels(req)))
开发者ID:lkraav,项目名称:trachacks,代码行数:10,代码来源:admin.py

示例7: test_process_view_configs_empty

    def test_process_view_configs_empty(self):
        req = Mock(method='GET', chrome={}, href=Href('/'),
                   perm=PermissionCache(self.env, 'joe'))

        provider = BuildConfigurationsAdminPageProvider(self.env)
        template_name, data = provider.render_admin_panel(
            req, 'bitten', 'configs', ''
        )

        self.assertEqual('bitten_admin_configs.html', template_name)
        self.assertEqual([], data['configs'])
开发者ID:lkraav,项目名称:trachacks,代码行数:11,代码来源:admin.py

示例8: test_process_add_config_no_name

    def test_process_add_config_no_name(self):
        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   chrome={'warnings': []}, href=Href('/'),
                   authname='joe', args={'add': ''})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', '')
            self.fail('Expected TracError')

        except TracError, e:
            self.assertEqual('Missing required field "name".', e.message)
            self.assertEqual('Add Configuration', e.title)
开发者ID:lkraav,项目名称:trachacks,代码行数:13,代码来源:admin.py

示例9: test_process_add_config_invalid_name

    def test_process_add_config_invalid_name(self):
        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   chrome={'warnings': []}, href=Href('/'), authname='joe',
                   args={'add': '', 'name': 'no spaces allowed'})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', '')
            self.fail('Expected TracError')

        except TracError, e:
            self.assertEqual('The field "name" may only contain letters, '
                             'digits, periods, or dashes.', e.message)
            self.assertEqual('Add Configuration', e.title)
开发者ID:lkraav,项目名称:trachacks,代码行数:14,代码来源:admin.py

示例10: test_process_remove_config_bad_selection

    def test_process_remove_config_bad_selection(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   args={'remove': '', 'sel': 'baz'})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', '')
            self.fail('Expected TracError')

        except TracError, e:
            self.assertEqual("Configuration 'baz' not found", e.message)
开发者ID:lkraav,项目名称:trachacks,代码行数:14,代码来源:admin.py

示例11: test_process_update_config_no_name

    def test_process_update_config_no_name(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   args={'save': '', 'name': ''}, authname='joe',
                   chrome={'warnings':[]}, href=Href('/'))

        provider = BuildConfigurationsAdminPageProvider(self.env)
        provider.render_admin_panel(req, 'bitten', 'configs', 'foo')

        self.failUnless(req.chrome['warnings'], "No warnings?")
        self.assertEquals(['Missing required field "name".'],
                            req.chrome['warnings'])
开发者ID:lkraav,项目名称:trachacks,代码行数:14,代码来源:admin.py

示例12: test_process_update_config_non_wellformed_recipe

    def test_process_update_config_non_wellformed_recipe(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   authname='joe', chrome={'warnings': []}, href=Href('/'),
                   args={'save': '', 'name': 'foo', 'recipe': 'not_xml'})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        provider.render_admin_panel(req, 'bitten', 'configs', 'foo')

        self.failUnless(req.chrome['warnings'], "No warnings?")
        self.assertEquals(['Failure parsing recipe: syntax error: line 1, ' \
                        'column 0.'], req.chrome['warnings'])
开发者ID:lkraav,项目名称:trachacks,代码行数:14,代码来源:admin.py

示例13: test_process_update_config_invalid_recipe

    def test_process_update_config_invalid_recipe(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   authname='joe', chrome={'warnings': []}, href=Href('/'),
                   args={'save': '', 'name': 'foo',
                         'recipe': '<build><step /></build>'})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        provider.render_admin_panel(req, 'bitten', 'configs', 'foo')
        
        self.failUnless(req.chrome['warnings'], "No warnings?")
        self.assertEquals(req.chrome['warnings'],
                    ['Invalid Recipe: Steps must have an "id" attribute.'])
开发者ID:lkraav,项目名称:trachacks,代码行数:15,代码来源:admin.py

示例14: test_process_update_config_invalid_name

    def test_process_update_config_invalid_name(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
                   args={'save': '', 'name': 'no spaces allowed'},
                   authname='joe', chrome={'warnings': []},
                   href=Href('/'))

        provider = BuildConfigurationsAdminPageProvider(self.env)
        provider.render_admin_panel(req, 'bitten', 'configs', 'foo')

        self.failUnless(req.chrome['warnings'], "No warnings?")
        self.assertEquals(req.chrome['warnings'], ['The field "name" may ' \
                        'only contain letters, digits, periods, or dashes.'])
开发者ID:lkraav,项目名称:trachacks,代码行数:15,代码来源:admin.py

示例15: test_process_new_platform_no_name

    def test_process_new_platform_no_name(self):
        BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
                    active=True).insert()

        data = {}
        req = Mock(method='POST', chrome={}, hdf=data, href=Href('/'),
                   perm=PermissionCache(self.env, 'joe'),
                   args={'new': '', 'platform_name': ''})

        provider = BuildConfigurationsAdminPageProvider(self.env)
        try:
            provider.render_admin_panel(req, 'bitten', 'configs', 'foo')
            self.fail("No TracError?")
        except Exception, e:
            self.assertEquals(e.message, 'Missing required field "name"')
            self.assertEquals(e.title, 'Missing field')
开发者ID:lkraav,项目名称:trachacks,代码行数:16,代码来源:admin.py


注:本文中的bitten.admin.BuildConfigurationsAdminPageProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。