• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.RegistrationFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_make_child_embargoed_registration_public_asks_all_admins_in_tree

    def test_make_child_embargoed_registration_public_asks_all_admins_in_tree(self, mock_ask):
        # Initiate and approve embargo
        node = NodeFactory(creator=self.user)
        c1 = AuthUserFactory()
        child = NodeFactory(parent=node, creator=c1)
        c2 = AuthUserFactory()
        NodeFactory(parent=child, creator=c2)
        registration = RegistrationFactory(project=node)

        registration.embargo_registration(
            self.user,
            datetime.datetime.utcnow() + datetime.timedelta(days=10)
        )
        for user_id, embargo_tokens in registration.embargo.approval_state.iteritems():
            approval_token = embargo_tokens['approval_token']
            registration.embargo.approve_embargo(User.load(user_id), approval_token)
        self.registration.save()

        res = self.app.post(
            registration.api_url_for('project_set_privacy', permissions='public'),
            auth=self.user.auth
        )
        assert_equal(res.status_code, 200)
        asked_admins = [(admin._id, n._id) for admin, n in mock_ask.call_args[0][0]]
        for admin, node in registration.get_admin_contributors_recursive():
            assert_in((admin._id, node._id), asked_admins)
开发者ID:baylee-d,项目名称:osf.io,代码行数:26,代码来源:test_embargoes.py


示例2: test_cancelling_registration_approval_deletes_component_registrations

    def test_cancelling_registration_approval_deletes_component_registrations(self):
        component = NodeFactory(
            creator=self.user,
            parent=self.project,
            title='Component'
        )
        NodeFactory(
            creator=self.user,
            parent=component,
            title='Subcomponent'
        )
        project_registration = RegistrationFactory(project=self.project)
        component_registration = project_registration.nodes[0]
        subcomponent_registration = component_registration.nodes[0]
        project_registration.require_approval(
            self.user
        )
        project_registration.save()

        rejection_token = project_registration.registration_approval.approval_state[self.user._id]['rejection_token']
        project_registration.registration_approval.reject(self.user, rejection_token)
        assert_equal(project_registration.registration_approval.state, Sanction.REJECTED)
        assert_true(project_registration.is_deleted)
        assert_true(component_registration.is_deleted)
        assert_true(subcomponent_registration.is_deleted)
开发者ID:mauromsl,项目名称:osf.io,代码行数:25,代码来源:test_registration_approvals.py


示例3: test_rejecting_embargo_for_existing_registration_does_not_deleted_component_registrations

    def test_rejecting_embargo_for_existing_registration_does_not_deleted_component_registrations(self):
        component = NodeFactory(
            creator=self.user,
            parent=self.project,
            title='Component'
        )
        subcomponent = NodeFactory(
            creator=self.user,
            parent=component,
            title='Subcomponent'
        )
        project_registration = RegistrationFactory(project=self.project)
        component_registration = project_registration.nodes[0]
        subcomponent_registration = component_registration.nodes[0]
        project_registration.embargo_registration(
            self.user,
            datetime.datetime.utcnow() + datetime.timedelta(days=10),
            for_existing_registration=True
        )

        rejection_token = project_registration.embargo.approval_state[self.user._id]['rejection_token']
        project_registration.embargo.disapprove_embargo(self.user, rejection_token)
        project_registration.save()
        assert_equal(project_registration.embargo.state, Embargo.REJECTED)
        assert_false(project_registration.is_deleted)
        assert_false(component_registration.is_deleted)
        assert_false(subcomponent_registration.is_deleted)
开发者ID:mchelen,项目名称:osf.io,代码行数:27,代码来源:test_embargoes.py


示例4: test_cannot_access_retracted_registrations_list

 def test_cannot_access_retracted_registrations_list(self):
     registration = RegistrationFactory(creator=self.user, project=self.public_project)
     retraction = RetractedRegistrationFactory(registration=registration, user=registration.creator)
     registration.save()
     url = '/{}nodes/{}/registrations/'.format(API_BASE, registration._id)
     res = self.app.get(url, auth=self.user.auth, expect_errors=True)
     assert_equal(res.status_code, 404)
开发者ID:545zhou,项目名称:osf.io,代码行数:7,代码来源:test_node_registrations_list.py


示例5: test_cannot_update_a_retraction

 def test_cannot_update_a_retraction(self):
     registration = RegistrationFactory(creator=self.user, project=self.public_project)
     url = "/{}nodes/{}/".format(API_BASE, registration._id)
     retraction = RetractedRegistrationFactory(registration=registration, user=registration.creator)
     res = self.app.put_json_api(
         url,
         {
             "data": {
                 "id": registration._id,
                 "type": "nodes",
                 "attributes": {
                     "title": fake.catch_phrase(),
                     "description": fake.bs(),
                     "category": "hypothesis",
                     "public": True,
                 },
             }
         },
         auth=self.user.auth,
         expect_errors=True,
     )
     registration.reload()
     assert_equal(res.status_code, 404)
     assert_equal(registration.title, registration.title)
     assert_equal(registration.description, registration.description)
开发者ID:kch8qx,项目名称:osf.io,代码行数:25,代码来源:test_node_detail.py


示例6: test_view_project_pending_registration_for_admin_contributor_does_contain_cancel_link

    def test_view_project_pending_registration_for_admin_contributor_does_contain_cancel_link(self):
        pending_reg = RegistrationFactory(project=self.node, archive=True)
        assert_true(pending_reg.is_pending_registration)
        result = _view_project(pending_reg, Auth(self.user))

        assert_not_equal(result["node"]["disapproval_link"], "")
        assert_in("/?token=", result["node"]["disapproval_link"])
        pending_reg.remove()
开发者ID:kch8qx,项目名称:osf.io,代码行数:8,代码来源:test_serializers.py


示例7: test_cannot_delete_a_retraction

 def test_cannot_delete_a_retraction(self):
     registration = RegistrationFactory(creator=self.user, project=self.public_project)
     url = '/{}nodes/{}/'.format(API_BASE, registration._id)
     retraction = RetractedRegistrationFactory(registration=registration, user=registration.creator)
     res = self.app.delete_json_api(url, auth=self.user.auth, expect_errors=True)
     registration.reload()
     assert_equal(res.status_code, 404)
     assert_equal(registration.title, registration.title)
     assert_equal(registration.description, registration.description)
开发者ID:mauromsl,项目名称:osf.io,代码行数:9,代码来源:test_node_detail.py


示例8: test_has_permission_on_parent_node_metadata_pass_if_registration

    def test_has_permission_on_parent_node_metadata_pass_if_registration(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, parent=self.node, is_public=False)

        component_registration = RegistrationFactory(project=component, creator=component_admin)

        assert_false(component_registration.has_permission(self.user, 'read'))
        res = views.check_access(component_registration, Auth(user=self.user), 'metadata', None)
        assert_true(res)
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_addons.py


示例9: test_view_project_pending_registration_for_write_contributor_does_not_contain_cancel_link

    def test_view_project_pending_registration_for_write_contributor_does_not_contain_cancel_link(self):
        write_user = UserFactory()
        self.node.add_contributor(write_user, permissions=permissions.WRITE, auth=Auth(self.user), save=True)
        pending_reg = RegistrationFactory(project=self.node, archive=True)
        assert_true(pending_reg.is_pending_registration)
        result = _view_project(pending_reg, Auth(write_user))

        assert_equal(result["node"]["disapproval_link"], "")
        pending_reg.remove()
开发者ID:kch8qx,项目名称:osf.io,代码行数:9,代码来源:test_serializers.py


示例10: test_new_draft_registration_on_registration

 def test_new_draft_registration_on_registration(self):
     target = RegistrationFactory(user=self.user)
     payload = {
         'schema_name': self.meta_schema.name,
         'schema_version': self.meta_schema.schema_version
     }
     url = target.web_url_for('new_draft_registration')
     res = self.app.post(url, payload, auth=self.user.auth, expect_errors=True)
     assert_equal(res.status_code, http.FORBIDDEN)
开发者ID:Alpani,项目名称:osf.io,代码行数:9,代码来源:test_views.py


示例11: test_is_public_node_register_page

 def test_is_public_node_register_page(self):
     self.node.is_public = True
     self.node.save()
     reg = RegistrationFactory(project=self.node)
     reg.is_public = True
     reg.save()
     url = reg.web_url_for('node_register_page')
     res = self.app.get(url, auth=None)
     assert_equal(res.status_code, http.OK)
开发者ID:Alpani,项目名称:osf.io,代码行数:9,代码来源:test_views.py


示例12: test_register_draft_registration_already_registered

 def test_register_draft_registration_already_registered(self):
     reg = RegistrationFactory(user=self.user)
     res = self.app.post_json(
         reg.api_url_for('register_draft_registration', draft_id=self.draft._id),
         self.invalid_payload,
         auth=self.user.auth,
         expect_errors=True
     )
     assert_equal(res.status_code, http.BAD_REQUEST)
开发者ID:Alpani,项目名称:osf.io,代码行数:9,代码来源:test_views.py


示例13: test_check_draft_state_registered_but_deleted

 def test_check_draft_state_registered_but_deleted(self):
     reg = RegistrationFactory()
     self.draft.registered_node = reg
     reg.is_deleted = True
     self.draft.save()
     try:
         draft_views.check_draft_state(self.draft)
     except Exception:
         self.fail()
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:9,代码来源:test_views.py


示例14: test_non_admin_can_view_node_register_page

 def test_non_admin_can_view_node_register_page(self):
     non_admin = AuthUserFactory()
     self.node.add_contributor(
         non_admin,
         permissions.DEFAULT_CONTRIBUTOR_PERMISSIONS,
         auth=self.auth,
         save=True
     )
     reg = RegistrationFactory(project=self.node)
     url = reg.web_url_for('node_register_page')
     res = self.app.get(url, auth=non_admin.auth)
     assert_equal(res.status_code, http.OK)
开发者ID:Alpani,项目名称:osf.io,代码行数:12,代码来源:test_views.py


示例15: test_check_draft_state_registered_and_deleted_and_approved

    def test_check_draft_state_registered_and_deleted_and_approved(self):
        reg = RegistrationFactory()
        self.draft.registered_node = reg
        self.draft.save()
        reg.is_deleted = True
        reg.save()

        with mock.patch('website.project.model.DraftRegistration.is_approved', mock.PropertyMock(return_value=True)):
            try:
                draft_views.check_draft_state(self.draft)
            except HTTPError:
                self.fail()
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:12,代码来源:test_views.py


示例16: test_draft_with_deleted_registered_node_shows_up_in_draft_list

 def test_draft_with_deleted_registered_node_shows_up_in_draft_list(self):
     reg = RegistrationFactory(project=self.public_project)
     self.draft_registration.registered_node = reg
     self.draft_registration.save()
     reg.is_deleted = True
     reg.save()
     res = self.app.get(self.url, auth=self.user.auth)
     assert_equal(res.status_code, 200)
     data = res.json["data"]
     assert_equal(len(data), 1)
     assert_equal(data[0]["attributes"]["registration_supplement"], self.schema._id)
     assert_equal(data[0]["id"], self.draft_registration._id)
     assert_equal(data[0]["attributes"]["registration_metadata"], {})
开发者ID:ccfair,项目名称:osf.io,代码行数:13,代码来源:test_node_draft_registration_list.py


示例17: test__on_complete_makes_project_and_components_public

    def test__on_complete_makes_project_and_components_public(self):
        project_admin = UserFactory()
        child_admin = UserFactory()
        grandchild_admin = UserFactory()

        project = ProjectFactory(creator=project_admin, is_public=False)
        child = NodeFactory(creator=child_admin, parent=project, is_public=False)
        grandchild = NodeFactory(creator=grandchild_admin, parent=child, is_public=False)  # noqa

        registration = RegistrationFactory(project=project)
        registration._initiate_retraction(self.user)
        registration.retraction._on_complete(self.user)
        for each in registration.node_and_primary_descendants():
            assert_true(each.is_public)
开发者ID:baylee-d,项目名称:osf.io,代码行数:14,代码来源:test_retractions.py


示例18: test_cancelling_embargo_deletes_component_registrations

    def test_cancelling_embargo_deletes_component_registrations(self):
        component = NodeFactory(creator=self.user, parent=self.project, title="Component")
        subcomponent = NodeFactory(creator=self.user, parent=component, title="Subcomponent")
        project_registration = RegistrationFactory(project=self.project)
        component_registration = project_registration.nodes[0]
        subcomponent_registration = component_registration.nodes[0]
        project_registration.embargo_registration(self.user, datetime.datetime.utcnow() + datetime.timedelta(days=10))
        project_registration.save()

        rejection_token = project_registration.embargo.approval_state[self.user._id]["rejection_token"]
        project_registration.embargo.disapprove_embargo(self.user, rejection_token)
        assert_equal(project_registration.embargo.state, Embargo.REJECTED)
        assert_true(project_registration.is_deleted)
        assert_true(component_registration.is_deleted)
        assert_true(subcomponent_registration.is_deleted)
开发者ID:caseyrygt,项目名称:osf.io,代码行数:15,代码来源:test_registration_embargoes.py


示例19: setUp

    def setUp(self):
        super(RegistrationEmbargoViewsTestCase, self).setUp()
        ensure_schemas()
        self.user = AuthUserFactory()
        self.project = ProjectFactory(creator=self.user)
        self.draft = DraftRegistrationFactory(branched_from=self.project)
        self.registration = RegistrationFactory(project=self.project, creator=self.user)

        current_month = datetime.datetime.now().strftime("%B")
        current_year = datetime.datetime.now().strftime("%Y")

        self.valid_make_public_payload = json.dumps({
            u'embargoEndDate': u'Fri, 01, {month} {year} 00:00:00 GMT'.format(
                month=current_month,
                year=current_year
            ),
            u'registrationChoice': 'immediate',
            u'summary': unicode(fake.sentence())
        })
        valid_date = datetime.datetime.now() + datetime.timedelta(days=180)
        self.valid_embargo_payload = json.dumps({
            u'embargoEndDate': unicode(valid_date.strftime('%a, %d, %B %Y %H:%M:%S')) + u' GMT',
            u'registrationChoice': 'embargo',
            u'summary': unicode(fake.sentence())
        })
        self.invalid_embargo_date_payload = json.dumps({
            u'embargoEndDate': u"Thu, 01 {month} {year} 05:00:00 GMT".format(
                month=current_month,
                year=str(int(current_year)-1)
            ),
            u'registrationChoice': 'embargo',
            u'summary': unicode(fake.sentence())
        })
开发者ID:mchelen,项目名称:osf.io,代码行数:33,代码来源:test_embargoes.py


示例20: _set_up_public_registration_with_wiki_page

 def _set_up_public_registration_with_wiki_page(self):
     self._set_up_public_project_with_wiki_page()
     self.public_registration = RegistrationFactory(project=self.public_project, user=self.user, is_public=True)
     self.public_registration_wiki_id = self.public_registration.wiki_pages_versions['home'][0]
     self.public_registration.wiki_pages_current = {'home': self.public_registration_wiki_id}
     self.public_registration.save()
     self.public_registration_url = '/{}registrations/{}/wikis/'.format(API_BASE, self.public_registration._id)
开发者ID:baylee-d,项目名称:osf.io,代码行数:7,代码来源:test_node_wiki_list.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.TeamFactory类代码示例发布时间:2022-05-27
下一篇:
Python factories.ProjectFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap