本文整理汇总了Python中tests.factories.RegistrationFactory类的典型用法代码示例。如果您正苦于以下问题:Python RegistrationFactory类的具体用法?Python RegistrationFactory怎么用?Python RegistrationFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RegistrationFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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)
示例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)
示例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()
示例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)
示例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)
示例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)
示例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()
示例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)
示例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()