本文整理汇总了Python中tests.factories.PreprintFactory.set_preprint_license方法的典型用法代码示例。如果您正苦于以下问题:Python PreprintFactory.set_preprint_license方法的具体用法?Python PreprintFactory.set_preprint_license怎么用?Python PreprintFactory.set_preprint_license使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.PreprintFactory
的用法示例。
在下文中一共展示了PreprintFactory.set_preprint_license方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPreprintUpdateLicense
# 需要导入模块: from tests.factories import PreprintFactory [as 别名]
# 或者: from tests.factories.PreprintFactory import set_preprint_license [as 别名]
#.........这里部分代码省略.........
def test_non_contributor_cannot_update_license(self):
data = self.make_payload(
node_id=self.preprint._id,
license_id=self.cc0_license._id
)
res = self.make_request(self.url, data, auth=self.non_contributor.auth, expect_errors=True)
assert_equal(res.status_code, 403)
assert_equal(res.json['errors'][0]['detail'], 'You do not have permission to perform this action.')
def test_unauthenticated_user_cannot_update_license(self):
data = self.make_payload(
node_id=self.preprint._id,
license_id=self.cc0_license._id
)
res = self.make_request(self.url, data, expect_errors=True)
assert_equal(res.status_code, 401)
assert_equal(res.json['errors'][0]['detail'], 'Authentication credentials were not provided.')
def test_update_preprint_with_invalid_license_for_provider(self):
data = self.make_payload(
node_id=self.preprint._id,
license_id=self.mit_license._id
)
assert_equal(self.preprint.license, None)
res = self.make_request(self.url, data, auth=self.admin_contributor.auth, expect_errors=True)
assert_equal(res.status_code, 403)
assert_equal(res.json['errors'][0]['detail'], 'Invalid license chosen for {}'.format(self.preprint_provider.name))
def test_update_preprint_with_existing_license_year_attribute_only(self):
self.preprint.set_preprint_license(
{
'id': self.no_license.id,
'year': '2014',
'copyrightHolders': ['Diane', 'Mr. Peanut Butter']
},
Auth(self.admin_contributor),
)
self.preprint.save()
assert_equal(self.preprint.license.node_license, self.no_license)
assert_equal(self.preprint.license.year, '2014')
assert_equal(self.preprint.license.copyright_holders, ['Diane', 'Mr. Peanut Butter'])
data = self.make_payload(
node_id=self.preprint._id,
license_year='2015'
)
res = self.make_request(self.url, data, auth=self.admin_contributor.auth)
assert_equal(res.status_code, 200)
self.preprint.license.reload()
assert_equal(self.preprint.license.node_license, self.no_license)
assert_equal(self.preprint.license.year, '2015')
assert_equal(self.preprint.license.copyright_holders, ['Diane', 'Mr. Peanut Butter'])
def test_update_preprint_with_existing_license_copyright_holders_attribute_only(self):
self.preprint.set_preprint_license(
{
'id': self.no_license.id,
'year': '2014',
'copyrightHolders': ['Diane', 'Mr. Peanut Butter']