當前位置: 首頁>>代碼示例>>Python>>正文


Python factories.Organization方法代碼示例

本文整理匯總了Python中ckan.tests.factories.Organization方法的典型用法代碼示例。如果您正苦於以下問題:Python factories.Organization方法的具體用法?Python factories.Organization怎麽用?Python factories.Organization使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ckan.tests.factories的用法示例。


在下文中一共展示了factories.Organization方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_run_auth_user

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [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

示例2: test_delete_auth_user

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [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

示例3: test_show_anon_public_dataset

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [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

示例4: test_resource_delete_editor

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [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

示例5: test_send_invite_email_with_org

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [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

示例6: test_package_dictize_owner_org

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_package_dictize_owner_org(self):
        org = factories.Organization(name='test_package_dictize')
        dataset = factories.Dataset(owner_org=org['id'])
        dataset_obj = model.Package.get(dataset['id'])
        context = {'model': model, 'session': model.Session}

        result = model_dictize.package_dictize(dataset_obj, context)

        assert_equal(result['owner_org'], org['id'])
        assert_equal_for_keys(result['organization'], org,
                              'name')
        expected_dict = {
            u'approval_status': u'approved',
            u'description': u'Just another test organization.',
            u'image_url': u'http://placekitten.com/g/200/100',
            u'is_organization': True,
            u'name': u'test_package_dictize',
            u'state': u'active',
            u'title': u'Test Organization',
            u'type': u'organization'
        }
        self.assert_equals_expected(expected_dict, result['organization']) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:24,代碼來源:test_model_dictize.py

示例7: test_org_user_can_delete

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_org_user_can_delete(self):
        user = factories.User()
        org_users = [{'name': user['name'], 'capacity': 'editor'}]
        org = factories.Organization(users=org_users)
        dataset = factories.Dataset(owner_org=org['id'],
                                    resources=[factories.Resource()],
                                    user=user)

        resource_view = factories.ResourceView(
            resource_id=dataset['resources'][0]['id']
        )

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

        response = helpers.call_auth('resource_view_delete', context=context,
                                     id=resource_view['id'])

        assert_equals(response, True) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:20,代碼來源:test_delete.py

示例8: test_not_authorized_if_user_has_no_permissions_on_dataset

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_not_authorized_if_user_has_no_permissions_on_dataset(self):

        org = factories.Organization()

        user = factories.User()

        member = {'username': user['name'],
                  'role': 'admin',
                  'id': org['id']}
        helpers.call_action('organization_member_create', **member)

        user_2 = factories.User()

        dataset = factories.Dataset(owner_org=org['id'])

        resource = factories.Resource(package_id=dataset['id'])

        context = {'user': user_2['name'], 'model': core_model}
        nose.tools.assert_raises(logic.NotAuthorized, helpers.call_auth,
                                 'resource_create_default_resource_views',
                                 context=context,
                                 resource=resource) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:24,代碼來源:test_create.py

示例9: test_package_owner_org_changed

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_package_owner_org_changed(self):
        '''A package with an owner_org can have it changed.'''

        sysadmin = factories.Sysadmin()
        org_1 = factories.Organization()
        org_2 = factories.Organization()
        dataset = factories.Dataset(owner_org=org_1['id'])
        context = {
            'user': sysadmin['name'],
        }
        assert dataset['owner_org'] == org_1['id']
        helpers.call_action('package_owner_org_update',
                            context=context,
                            id=dataset['id'],
                            organization_id=org_2['id'])
        dataset_obj = model.Package.get(dataset['id'])
        assert dataset_obj.owner_org == org_2['id'] 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:19,代碼來源:test_update.py

示例10: test_organization_show_packages_returned

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_organization_show_packages_returned(self):

        user_name = helpers.call_action('get_site_user')['name']

        org = factories.Organization()

        datasets = [
            {'name': 'dataset_1', 'owner_org': org['name']},
            {'name': 'dataset_2', 'owner_org': org['name']},
        ]

        for dataset in datasets:
            helpers.call_action('package_create',
                                context={'user': user_name},
                                **dataset)

        org_dict = helpers.call_action('organization_show', id=org['id'],
                                       include_datasets=True)

        assert len(org_dict['packages']) == 2
        assert org_dict['package_count'] == 2 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:23,代碼來源:test_get.py

示例11: test_organization_show_private_packages_not_returned

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_organization_show_private_packages_not_returned(self):

        user_name = helpers.call_action('get_site_user')['name']

        org = factories.Organization()

        datasets = [
            {'name': 'dataset_1', 'owner_org': org['name']},
            {'name': 'dataset_2', 'owner_org': org['name'], 'private': True},
        ]

        for dataset in datasets:
            helpers.call_action('package_create',
                                context={'user': user_name},
                                **dataset)

        org_dict = helpers.call_action('organization_show', id=org['id'],
                                       include_datasets=True)

        assert len(org_dict['packages']) == 1
        assert org_dict['packages'][0]['name'] == 'dataset_1'
        assert org_dict['package_count'] == 1 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:24,代碼來源:test_get.py

示例12: test_user_show_include_datasets_excludes_draft_and_private

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_user_show_include_datasets_excludes_draft_and_private(self):

        user = factories.User()
        org = factories.Organization(user=user)
        dataset = factories.Dataset(user=user)
        factories.Dataset(user=user, state='deleted')
        factories.Dataset(user=user, state='draft')
        factories.Dataset(user=user, private=True, owner_org=org['name'])

        got_user = helpers.call_action('user_show',
                                       include_datasets=True,
                                       id=user['id'])

        assert len(got_user['datasets']) == 1
        assert got_user['datasets'][0]['name'] == dataset['name']
        assert got_user['number_created_packages'] == 1 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:18,代碼來源:test_get.py

示例13: test_user_show_include_datasets_includes_draft_sysadmin

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_user_show_include_datasets_includes_draft_sysadmin(self):
        # sysadmin should see the draft and private datasets

        user = factories.User()
        sysadmin = factories.Sysadmin()
        org = factories.Organization(user=user)
        factories.Dataset(user=user)
        dataset_deleted = factories.Dataset(user=user, state='deleted')
        factories.Dataset(user=user, state='draft')
        factories.Dataset(user=user, private=True, owner_org=org['name'])

        got_user = helpers.call_action('user_show',
                                       context={'user': sysadmin['name']},
                                       include_datasets=True,
                                       id=user['id'])

        eq(len(got_user['datasets']), 3)
        datasets_got = set([user_['name'] for user_ in got_user['datasets']])
        assert dataset_deleted['name'] not in datasets_got
        eq(got_user['number_created_packages'], 3) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:22,代碼來源:test_get.py

示例14: test_package_search_with_fq_excludes_private

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_package_search_with_fq_excludes_private(self):
        '''
        package_search() with fq capacity:private should not return private
        and draft datasets.
        '''
        user = factories.User()
        org = factories.Organization(user=user)
        dataset = factories.Dataset(user=user)
        factories.Dataset(user=user, state='deleted')
        factories.Dataset(user=user, state='draft')
        factories.Dataset(user=user, private=True, owner_org=org['name'])

        fq = "capacity:private"
        results = helpers.call_action('package_search', fq=fq)['results']

        eq(len(results), 1)
        eq(results[0]['name'], dataset['name']) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:19,代碼來源:test_get.py

示例15: test_package_search_with_fq_excludes_drafts

# 需要導入模塊: from ckan.tests import factories [as 別名]
# 或者: from ckan.tests.factories import Organization [as 別名]
def test_package_search_with_fq_excludes_drafts(self):
        '''
        An anon user can't use fq drafts to get draft datasets. Nothing is
        returned.
        '''
        user = factories.User()
        other_user = factories.User()
        org = factories.Organization(user=user)
        factories.Dataset(user=user, name="dataset")
        factories.Dataset(user=other_user, name="other-dataset")
        factories.Dataset(user=user, state='deleted', name="deleted-dataset")
        factories.Dataset(user=user, state='draft', name="draft-dataset")
        factories.Dataset(user=other_user, state='draft', name="other-draft-dataset")
        factories.Dataset(user=user, private=True, owner_org=org['name'], name="private-dataset")

        fq = "state:draft"
        results = helpers.call_action('package_search', fq=fq)['results']

        eq(len(results), 0) 
開發者ID:italia,項目名稱:dati-ckan-docker,代碼行數:21,代碼來源:test_get.py


注:本文中的ckan.tests.factories.Organization方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。