當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。