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


Python base.get_default_metaschema函数代码示例

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


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

示例1: setUp

    def setUp(self):
        super(LinkedRegistrationsTestCase, self).setUp()
        self.mock_archive = mock.patch('website.archiver.tasks.archive')

        self.non_contributor = AuthUserFactory()
        self.read_contributor = AuthUserFactory()
        self.rw_contributor = AuthUserFactory()
        self.admin_contributor = AuthUserFactory()

        self.public_linked_registration = RegistrationFactory(is_public=True, creator=self.rw_contributor)
        self.private_linked_registration = RegistrationFactory(is_public=False, creator=self.rw_contributor)

        self.mock_archive.start()

        public_node = NodeFactory(creator=self.admin_contributor, is_public=True)
        public_node.add_contributor(self.rw_contributor, auth=Auth(self.admin_contributor))
        public_node.add_contributor(self.read_contributor, permissions=['read'], auth=Auth(self.admin_contributor))
        public_node.add_pointer(self.public_linked_registration, auth=Auth(self.admin_contributor))
        public_node.add_pointer(self.private_linked_registration, auth=Auth(self.rw_contributor))
        public_node.save()
        self.public_registration = public_node.register_node(get_default_metaschema(), Auth(self.admin_contributor), '', None)
        self.public_registration.is_public = True
        self.public_registration.save()

        private_node = NodeFactory(creator=self.admin_contributor)
        private_node.add_contributor(self.rw_contributor, auth=Auth(self.admin_contributor))
        private_node.add_contributor(self.read_contributor, permissions=['read'], auth=Auth(self.admin_contributor))
        private_node.add_pointer(self.public_linked_registration, auth=Auth(self.admin_contributor))
        private_node.add_pointer(self.private_linked_registration, auth=Auth(self.rw_contributor))
        private_node.save()
        self.private_registration = private_node.register_node(get_default_metaschema(), Auth(self.admin_contributor), '', None)
开发者ID:adlius,项目名称:osf.io,代码行数:31,代码来源:test_registration_linked_registrations.py

示例2: test_copied_from_id_trashed

 def test_copied_from_id_trashed(self, mock_archive):
     file_node = self.get_test_file()
     second_file_node = self.get_second_test_file()
     file_node.copied_from = second_file_node
     self.project.register_node(schema=get_default_metaschema(), auth=Auth(self.user), data=None)
     trashed_node = second_file_node.delete()
     assert_false(trashed_node.copied_from)
开发者ID:ycchen1989,项目名称:osf.io,代码行数:7,代码来源:test_addons.py

示例3: test_s3_set_bucket_registered

    def test_s3_set_bucket_registered(self):
        registration = self.project.register_node(get_default_metaschema(), self.consolidated_auth, "", "")

        url = registration.api_url_for("s3_post_node_settings")
        res = self.app.post_json(url, {"s3_bucket": "hammertofall"}, auth=self.user.auth, expect_errors=True)

        assert_equal(res.status_code, http.BAD_REQUEST)
开发者ID:KAsante95,项目名称:osf.io,代码行数:7,代码来源:test_view.py

示例4: test_does_not_get_copied_to_registrations

 def test_does_not_get_copied_to_registrations(self, mock_archive):
     registration = self.project.register_node(
         schema=get_default_metaschema(),
         auth=Auth(user=self.project.creator),
         data='hodor',
     )
     assert_false(registration.has_addon('gitlab'))
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:7,代码来源:test_models.py

示例5: test_does_not_get_copied_to_registrations

 def test_does_not_get_copied_to_registrations(self, mock_errors, mock_archive):
     registration = self.node.register_node(
         schema=get_default_metaschema(),
         auth=Auth(user=self.node.creator),
         data='hodor'
     )
     assert_false(registration.has_addon('figshare'))
开发者ID:baylee-d,项目名称:osf.io,代码行数:7,代码来源:test_models.py

示例6: test_archived_from_url_without_copied_from

    def test_archived_from_url_without_copied_from(self, mock_archive):
        file_node = self.get_test_file()

        registered_node = self.project.register_node(
            schema=get_default_metaschema(),
            auth=Auth(self.user),
            data=None,
        )
        archived_from_url = views.get_archived_from_url(registered_node, file_node)
        assert_false(archived_from_url)
开发者ID:leb2dg,项目名称:osf.io,代码行数:10,代码来源:test_addons.py

示例7: test_s3_set_bucket_registered

    def test_s3_set_bucket_registered(self):
        registration = self.project.register_node(
            get_default_metaschema(), Auth(self.user), '', ''
        )

        url = registration.api_url_for('s3_set_config')
        res = self.app.put_json(
            url, {'s3_bucket': 'hammertofall'}, auth=self.user.auth,
            expect_errors=True,
        )

        assert_equal(res.status_code, http.BAD_REQUEST)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:12,代码来源:test_view.py

示例8: test_archived_from_url

    def test_archived_from_url(self, mock_archive):
        file_node = self.get_test_file()
        second_file_node = self.get_second_test_file()
        file_node.copied_from = second_file_node

        registered_node = self.project.register_node(schema=get_default_metaschema(), auth=Auth(self.user), data=None)

        archived_from_url = views.get_archived_from_url(registered_node, file_node)
        view_url = self.project.web_url_for(
            "addon_view_or_download_file", provider=file_node.provider, path=file_node.copied_from._id
        )
        assert_true(archived_from_url)
        assert_urls_equal(archived_from_url, view_url)
开发者ID:ycchen1989,项目名称:osf.io,代码行数:13,代码来源:test_addons.py

示例9: test_registration_wiki_pages_created_pre_registration_get_cloned

    def test_registration_wiki_pages_created_pre_registration_get_cloned(self):
        project = self.set_up_project_with_wiki_page()
        registration = project.register_node(get_default_metaschema(), Auth(self.user), "", None)
        # reset wiki pages for test
        registration.wiki_pages_versions = project.wiki_pages_versions
        registration.wiki_pages_current = project.wiki_pages_current
        registration.save()

        main()
        registration.reload()
        wiki_versions = registration.wiki_pages_versions[self.wiki.page_name]

        current_wiki = NodeWikiPage.load(registration.wiki_pages_current[self.current_wiki.page_name])
        assert_equal(current_wiki.node, registration)
        assert_not_equal(current_wiki._id, self.current_wiki._id)

        wiki_version = NodeWikiPage.load(wiki_versions[0])
        assert_equal(wiki_version.node, registration)
        assert_not_equal(wiki_version._id, self.current_wiki._id)
开发者ID:kch8qx,项目名称:osf.io,代码行数:19,代码来源:test_clone_wiki_pages.py

示例10: test_link_repo_registration

    def test_link_repo_registration(self, mock_branches):
        bitbucket_mock = self.bitbucket
        mock_branches.return_value = bitbucket_mock.branches.return_value

        registration = self.project.register_node(
            schema=get_default_metaschema(),
            auth=self.consolidated_auth,
            data=''
        )

        url = registration.api_url + 'bitbucket/settings/'
        res = self.app.post_json(
            url,
            {
                'bitbucket_user': 'queen',
                'bitbucket_repo': 'night at the opera',
            },
            auth=self.auth,
            expect_errors=True
        ).maybe_follow()

        assert_equal(res.status_code, 400)
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:22,代码来源:test_views.py

示例11: test_link_repo_registration

    def test_link_repo_registration(self, mock_branches):

        mock_branches.return_value = [
            Branch.from_json(dumps({
                'name': 'master',
                'commit': {
                    'sha': '6dcb09b5b57875f334f61aebed695e2e4193db5e',
                    'url': 'https://api.gitlab.com/repos/octocat/Hello-World/commits/c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc',
                }
            })),
            Branch.from_json(dumps({
                'name': 'develop',
                'commit': {
                    'sha': '6dcb09b5b57875asdasedawedawedwedaewdwdass',
                    'url': 'https://api.gitlab.com/repos/octocat/Hello-World/commits/cdcb09b5b57875asdasedawedawedwedaewdwdass',
                }
            }))
        ]

        registration = self.project.register_node(
            schema=get_default_metaschema(),
            auth=self.consolidated_auth,
            data=''
        )

        url = registration.api_url + 'gitlab/settings/'
        res = self.app.post_json(
            url,
            {
                'gitlab_user': 'queen',
                'gitlab_repo': 'night at the opera',
            },
            auth=self.auth,
            expect_errors=True
        ).maybe_follow()

        assert_equal(res.status_code, 400)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:37,代码来源:test_views.py

示例12: test_quickfiles_cannot_be_registered

 def test_quickfiles_cannot_be_registered(self, quickfiles, auth):
     with pytest.raises(NodeStateError):
         quickfiles.register_node(get_default_metaschema(), auth, '', None)
开发者ID:aaxelb,项目名称:osf.io,代码行数:3,代码来源:test_quickfiles.py

示例13: _create

    def _create(cls, target_class, project=None, is_public=False,
                schema=None, data=None,
                archive=False, embargo=None, registration_approval=None, retraction=None,
                *args, **kwargs):
        save_kwargs(**kwargs)
        user = None
        if project:
            user = project.creator
        user = kwargs.get('user') or kwargs.get('creator') or user or UserFactory()
        kwargs['creator'] = user
        # Original project to be registered
        project = project or target_class(*args, **kwargs)
        if user._id not in project.permissions:
            project.add_contributor(
                contributor=user,
                permissions=permissions.CREATOR_PERMISSIONS,
                log=False,
                save=False
            )
        project.save()

        # Default registration parameters
        schema = schema or get_default_metaschema()
        data = data or {'some': 'data'}
        auth = Auth(user=user)
        register = lambda: project.register_node(
            schema=schema,
            auth=auth,
            data=data
        )

        def add_approval_step(reg):
            if embargo:
                reg.embargo = embargo
            elif registration_approval:
                reg.registration_approval = registration_approval
            elif retraction:
                reg.retraction = retraction
            else:
                reg.require_approval(reg.creator)
            reg.save()
            reg.sanction.add_authorizer(reg.creator, reg)
            reg.sanction.save()

        if archive:
            reg = register()
            add_approval_step(reg)
        else:
            with patch('framework.celery_tasks.handlers.enqueue_task'):
                reg = register()
                add_approval_step(reg)
            with patch.object(reg.archive_job, 'archive_tree_finished', Mock(return_value=True)):
                reg.archive_job.status = ARCHIVER_SUCCESS
                reg.archive_job.save()
                reg.sanction.state = Sanction.APPROVED
                reg.sanction.save()
        ArchiveJob(
            src_node=project,
            dst_node=reg,
            initiator=user,
        )
        if is_public:
            reg.is_public = True
        reg.save()
        return reg
开发者ID:545zhou,项目名称:osf.io,代码行数:65,代码来源:factories.py

示例14: get_default_metaschema

import mock
import datetime

from django.http import HttpRequest
from nose import SkipTest
from nose.tools import assert_equal, assert_not_equal, assert_in

from framework.auth import Auth
from framework.celery_tasks.handlers import celery_teardown_request

from website.archiver import ARCHIVER_SUCCESS
from website.archiver import listeners as archiver_listeners
from website.project.sanctions import Sanction

from tests.base import get_default_metaschema
DEFAULT_METASCHEMA = get_default_metaschema()

def requires_module(module):
    def decorator(fn):
        @functools.wraps(fn)
        def wrapper(*args, **kwargs):
            try:
                __import__(module)
            except ImportError:
                raise SkipTest()
            return fn(*args, **kwargs)
        return wrapper
    return decorator


def assert_logs(log_action, node_key, index=-1):
开发者ID:baylee-d,项目名称:osf.io,代码行数:31,代码来源:utils.py

示例15: test_node_register_page_registration

 def test_node_register_page_registration(self, mock_archive):
     reg = self.node.register_node(get_default_metaschema(), self.auth, '', None)
     url = reg.web_url_for('node_register_page')
     res = self.app.get(url, auth=self.user.auth)
     assert_equal(res.status_code, http.OK)
开发者ID:icereval,项目名称:osf.io,代码行数:5,代码来源:test_views.py


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