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


Python factories.User方法代码示例

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


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

示例1: setup_class

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        p.load('datapusher')
        p.load('test_datapusher_plugin')

        resource = factories.Resource(url_type='datastore')
        cls.dataset = factories.Dataset(resources=[resource])

        cls.sysadmin_user = factories.User(name='testsysadmin', sysadmin=True)
        cls.normal_user = factories.User(name='annafan')
        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine)) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:19,代码来源:test_interfaces.py

示例2: test_run_auth_user

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_run_auth_user(self):

        user = factories.User()
        org = factories.Organization(
            users=[{'name': user['name'], 'capacity': 'editor'}])
        dataset = factories.Dataset(
            owner_org=org['id'], resources=[factories.Resource()])

        context = {
            'user': user['name'],
            'model': model
        }

        assert_equals(call_auth('resource_validation_run', context=context,
                                resource_id=dataset['resources'][0]['id']),
                      True) 
开发者ID:frictionlessdata,项目名称:ckanext-validation,代码行数:18,代码来源:test_logic.py

示例3: test_delete_auth_user

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_delete_auth_user(self):

        user = factories.User()
        org = factories.Organization(
            users=[{'name': user['name'], 'capacity': 'editor'}])
        dataset = factories.Dataset(
            owner_org=org['id'], resources=[factories.Resource()])

        context = {
            'user': user['name'],
            'model': model
        }

        assert_equals(call_auth('resource_validation_delete', context=context,
                                resource_id=dataset['resources'][0]['id']),
                      True) 
开发者ID:frictionlessdata,项目名称:ckanext-validation,代码行数:18,代码来源:test_logic.py

示例4: test_show_anon_public_dataset

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_show_anon_public_dataset(self):

        user = factories.User()
        org = factories.Organization()
        dataset = factories.Dataset(
            owner_org=org['id'], resources=[factories.Resource()],
            private=False)

        context = {
            'user': user['name'],
            'model': model
        }

        assert_equals(call_auth('resource_validation_show', context=context,
                                resource_id=dataset['resources'][0]['id']),
                      True) 
开发者ID:frictionlessdata,项目名称:ckanext-validation,代码行数:18,代码来源:test_logic.py

示例5: test_spatial_extra_bad_json

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_spatial_extra_bad_json(self):
        app = self._get_test_app()

        user = factories.User()
        env = {'REMOTE_USER': user['name'].encode('ascii')}
        dataset = factories.Dataset(user=user)

        offset = url_for(controller='package', action='edit', id=dataset['id'])
        res = app.get(offset, extra_environ=env)

        form = res.forms[1]
        form['extras__0__key'] = u'spatial'
        form['extras__0__value'] = u'{"Type":Bad Json]'

        res = helpers.webtest_submit(form, extra_environ=env, name='save')

        assert 'Error' in res, res
        assert 'Spatial' in res
        assert 'Error decoding JSON object' in res 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:test_package.py

示例6: test_spatial_extra_bad_geojson

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_spatial_extra_bad_geojson(self):
        app = self._get_test_app()

        user = factories.User()
        env = {'REMOTE_USER': user['name'].encode('ascii')}
        dataset = factories.Dataset(user=user)

        offset = url_for(controller='package', action='edit', id=dataset['id'])
        res = app.get(offset, extra_environ=env)

        form = res.forms[1]
        form['extras__0__key'] = u'spatial'
        form['extras__0__value'] = u'{"Type":"Bad_GeoJSON","a":2}'

        res = helpers.webtest_submit(form, extra_environ=env, name='save')

        assert 'Error' in res, res
        assert 'Spatial' in res
        assert 'Error creating geometry' in res 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:test_package.py

示例7: test_resource_delete_editor

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_resource_delete_editor(self):
        '''Normally organization admins can delete resources
        Our plugin prevents this by blocking delete organization.

        Ensure the delete button is not displayed (as only resource delete
        is checked for showing this)

        '''
        user = factories.User()
        owner_org = factories.Organization(
            users=[{'name': user['id'], 'capacity': 'admin'}]
        )
        dataset = factories.Dataset(owner_org=owner_org['id'])
        resource = factories.Resource(package_id=dataset['id'])
        with assert_raises(logic.NotAuthorized) as e:
            logic.check_access('resource_delete', {'user': user['name']}, {'id': resource['id']})

        assert_equal(e.exception.message, 'User %s not authorized to delete resource %s' % (user['name'], resource['id'])) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:test_example_iauthfunctions.py

示例8: _make_curators_group

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def _make_curators_group(self):
        '''This is a helper method for test methods to call when they want
        the 'curators' group to be created.

        '''
        sysadmin = factories.Sysadmin()

        # Create a user who will *not* be a member of the curators group.
        noncurator = factories.User()

        # Create a user who will be a member of the curators group.
        curator = factories.User()

        # Create the curators group, with the 'curator' user as a member.
        users = [{'name': curator['name'], 'capacity': 'member'}]
        curators_group = tests.call_action_api(self.app, 'group_create',
                                               apikey=sysadmin['apikey'],
                                               name='curators',
                                               users=users)

        return (noncurator, curator, curators_group) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:23,代码来源:test_example_iauthfunctions.py

示例9: test_group_create_with_no_curators_group

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_group_create_with_no_curators_group(self):
        '''Test that group_create returns a 404 when there's no curators group.

        With this version of the plugin group_create returns a spurious 404
        when a user _is_ logged-in but the site has no curators group.

        '''
        assert 'curators' not in tests.call_action_api(self.app, 'group_list')

        user = factories.User()

        response = tests.call_action_api(self.app, 'group_create',
                                         name='test_group',
                                         apikey=user['apikey'], status=404)
        assert response == {'__type': 'Not Found Error',
                            'message': 'Not found'} 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:18,代码来源:test_example_iauthfunctions.py

示例10: test_reset_password_custom_body

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_reset_password_custom_body(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        extra_vars = {
            'reset_link': mailer.get_reset_link(user_obj)
        }
        expected = render_jinja2('emails/reset_password.txt',
                                 extra_vars)
        body = self.get_email_body(msg[3])
        assert_equal(expected, body)
        assert_in('**test**', body) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:tests.py

示例11: test_invite_user_custom_subject

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_invite_user_custom_subject(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_invite(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        extra_vars = {
            'site_title': config.get('ckan.site_title'),
        }
        expected = render_jinja2('emails/invite_user_subject.txt',
                                 extra_vars)
        expected = expected.split('\n')[0]

        subject = self.get_email_subject(msg[3])
        assert_equal(expected, subject)
        assert_in('**test**', subject) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:tests.py

示例12: test_invite_user_custom_body

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_invite_user_custom_body(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_invite(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        extra_vars = {
            'reset_link': mailer.get_reset_link(user_obj),
            'user_name': user['name'],
            'site_title': config.get('ckan.site_title'),
        }
        expected = render_jinja2('emails/invite_user.txt',
                                 extra_vars)
        body = self.get_email_body(msg[3])
        assert_equal(expected, body)
        assert_in('**test**', body) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:tests.py

示例13: test_send_reset_email

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_send_reset_email(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [user['email']])
        assert 'Reset' in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(user_obj)
        expected_body = self.mime_encode(test_msg,
                                         user['name'])

        assert_in(expected_body, msg[3]) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:test_mailer.py

示例14: test_send_invite_email

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_send_invite_email(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])
        assert user_obj.reset_key is None, user_obj

        # send email
        mailer.send_invite(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [user['email']])
        test_msg = mailer.get_invite_body(user_obj)
        expected_body = self.mime_encode(test_msg,
                                         user['name'])

        assert_in(expected_body, msg[3])
        assert user_obj.reset_key is not None, user 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:test_mailer.py

示例15: test_send_invite_email_with_org

# 需要导入模块: from ckan.tests import factories [as 别名]
# 或者: from ckan.tests.factories import User [as 别名]
def test_send_invite_email_with_org(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        org = factories.Organization()
        role = 'admin'

        # send email
        mailer.send_invite(user_obj, group_dict=org, role=role)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        msg = msgs[0]
        body = self.get_email_body(msg[3])
        assert_in(org['title'], body)
        assert_in(h.roles_translated()[role], body) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:18,代码来源:test_mailer.py


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