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


Python DguCreateTestData.create_user方法代码示例

本文整理汇总了Python中ckanext.dgu.testtools.create_test_data.DguCreateTestData.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python DguCreateTestData.create_user方法的具体用法?Python DguCreateTestData.create_user怎么用?Python DguCreateTestData.create_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ckanext.dgu.testtools.create_test_data.DguCreateTestData的用法示例。


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

示例1: test_5_appoint_editor

# 需要导入模块: from ckanext.dgu.testtools.create_test_data import DguCreateTestData [as 别名]
# 或者: from ckanext.dgu.testtools.create_test_data.DguCreateTestData import create_user [as 别名]
    def test_5_appoint_editor(self):
        publisher_name = 'national-health-service'
        def check_related_publisher_properties():
            group = model.Group.by_name(publisher_name)
            # datasets
            assert_equal(set([grp.name for grp in group.packages()]),
                         set([u'directgov-cota']))
            # parents
            child_groups = [grp.name for grp in model.Group.by_name('dept-health').get_children_groups('organization')]
            assert publisher_name in child_groups, child_groups

        check_related_publisher_properties()

        DguCreateTestData.create_user(name='test_user')
        assert model.User.by_name(u'test_user')
        # Load form
        group = model.Group.by_name(unicode(publisher_name))
        offset = url_for('/publisher/users/%s' % publisher_name)
        res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER': 'nhsadmin'})
        assert 'Edit User Permissions' in res, res
        form = res.forms[1]
        assert_equal(form['users__0__name'].value, 'nhsadmin')
        assert_equal(form['users__0__capacity'].value, 'admin')
        assert_equal(form['users__1__name'].value, 'nhseditor')
        assert_equal(form['users__1__capacity'].value, 'editor')
        assert_equal(form['users__2__name'].value, 'user_d101')
        assert_equal(form['users__2__capacity'].value, 'editor')
        assert_equal(form['users__3__name'].value, '')

        # Edit the form
        form['users__3__name'] = 'test_user'
        res = form.submit('save', status=302, extra_environ={'REMOTE_USER': 'nhsadmin'})
        assert_equal(res.header_dict['Location'], 'http://localhost/publisher/national-health-service')

        # Check saved object
        group = model.Group.by_name(unicode(publisher_name))
        assert_equal(set([user.name for user in group.members_of_type(model.User, capacity='admin')]),
                     set(('nhsadmin',)))
        assert_equal(set([user.name for user in group.members_of_type(model.User, capacity='editor')]),
                     set(('nhseditor', 'user_d101', 'test_user')))

        check_related_publisher_properties()
开发者ID:datagovuk,项目名称:ckanext-dgu,代码行数:44,代码来源:test_publisher_forms.py


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