本文整理汇总了Python中tests.factories.RegistrationFactory.set_identifier_value方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationFactory.set_identifier_value方法的具体用法?Python RegistrationFactory.set_identifier_value怎么用?Python RegistrationFactory.set_identifier_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.RegistrationFactory
的用法示例。
在下文中一共展示了RegistrationFactory.set_identifier_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_node_csl
# 需要导入模块: from tests.factories import RegistrationFactory [as 别名]
# 或者: from tests.factories.RegistrationFactory import set_identifier_value [as 别名]
def test_node_csl(self):
node = RegistrationFactory()
node.set_identifier_value('doi', 'FK424601')
assert_equal(node.csl['DOI'], 'FK424601')
示例2: TestIdentifierViews
# 需要导入模块: from tests.factories import RegistrationFactory [as 别名]
# 或者: from tests.factories.RegistrationFactory import set_identifier_value [as 别名]
class TestIdentifierViews(OsfTestCase):
def setUp(self):
super(TestIdentifierViews, self).setUp()
self.user = AuthUserFactory()
self.node = RegistrationFactory(creator=self.user, is_public=True)
def test_get_identifiers(self):
self.node.set_identifier_value('doi', 'FK424601')
self.node.set_identifier_value('ark', 'fk224601')
res = self.app.get(self.node.api_url_for('node_identifiers_get'))
assert_equal(res.json['doi'], 'FK424601')
assert_equal(res.json['ark'], 'fk224601')
@httpretty.activate
def test_create_identifiers_not_exists(self):
identifier = self.node._id
url = furl.furl('https://ezid.cdlib.org/id')
doi = settings.EZID_FORMAT.format(namespace=settings.DOI_NAMESPACE, guid=identifier)
url.path.segments.append(doi)
httpretty.register_uri(
httpretty.PUT,
url.url,
body=to_anvl({
'success': '{doi}osf.io/{ident} | {ark}osf.io/{ident}'.format(
doi=settings.DOI_NAMESPACE,
ark=settings.ARK_NAMESPACE,
ident=identifier,
),
}),
status=201,
priority=1,
)
res = self.app.post(
self.node.api_url_for('node_identifiers_post'),
auth=self.user.auth,
)
self.node.reload()
assert_equal(
res.json['doi'],
self.node.get_identifier_value('doi')
)
assert_equal(
res.json['ark'],
self.node.get_identifier_value('ark')
)
assert_equal(res.status_code, 201)
@httpretty.activate
def test_create_identifiers_exists(self):
identifier = self.node._id
doi = settings.EZID_FORMAT.format(namespace=settings.DOI_NAMESPACE, guid=identifier)
url = furl.furl('https://ezid.cdlib.org/id')
url.path.segments.append(doi)
httpretty.register_uri(
httpretty.PUT,
url.url,
body='identifier already exists',
status=400,
)
httpretty.register_uri(
httpretty.GET,
url.url,
body=to_anvl({
'success': doi,
}),
status=200,
)
res = self.app.post(
self.node.api_url_for('node_identifiers_post'),
auth=self.user.auth,
)
self.node.reload()
assert_equal(
res.json['doi'],
self.node.get_identifier_value('doi')
)
assert_equal(
res.json['ark'],
self.node.get_identifier_value('ark')
)
assert_equal(res.status_code, 201)
def test_get_by_identifier(self):
self.node.set_identifier_value('doi', 'FK424601')
self.node.set_identifier_value('ark', 'fk224601')
res_doi = self.app.get(
self.node.web_url_for(
'get_referent_by_identifier',
category='doi',
value=self.node.get_identifier_value('doi'),
),
)
assert_equal(res_doi.status_code, 302)
assert_urls_equal(res_doi.headers['Location'], self.node.absolute_url)
res_ark = self.app.get(
self.node.web_url_for(
'get_referent_by_identifier',
category='ark',
#.........这里部分代码省略.........
示例3: test_mixin_set_create
# 需要导入模块: from tests.factories import RegistrationFactory [as 别名]
# 或者: from tests.factories.RegistrationFactory import set_identifier_value [as 别名]
def test_mixin_set_create(self):
node = RegistrationFactory()
assert_is_none(node.get_identifier('dogid'))
node.set_identifier_value('dogid', 'dog:1')
assert_equal(node.get_identifier_value('dogid'), 'dog:1')