本文整理汇总了Python中factories.db.invenio_records.TestRecordMetadata类的典型用法代码示例。如果您正苦于以下问题:Python TestRecordMetadata类的具体用法?Python TestRecordMetadata怎么用?Python TestRecordMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestRecordMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_jinja_template_prints_citation_count
def test_jinja_template_prints_citation_count(isolated_api_client):
record_json = {
'control_number': 321,
'titles': [
{
'title': 'The Invincible Ironman',
},
],
}
record_1 = TestRecordMetadata.create_from_kwargs(json=record_json).inspire_record
ref = {'control_number': 4321, 'references': [{'record': {'$ref': record_1._get_ref()}}]}
TestRecordMetadata.create_from_kwargs(json=ref)
response = isolated_api_client.get(
'/literature/321',
headers={'Accept': 'application/vnd+inspire.latex.eu+x-latex'}
)
expected = """\
%\\cite{321}
\\bibitem{321}
%``The Invincible Ironman,''
%1 citations counted in INSPIRE as of 19 Dec 1994"""
result = response.data
assert dedent(expected) == result
示例2: test_merge_with_conflicts_rootful
def test_merge_with_conflicts_rootful(
mocked_api_request_magpie,
mocked_beard_api,
workflow_app,
mocked_external_services,
disable_file_upload,
enable_merge_on_update,
):
with patch('inspire_json_merger.config.ArxivOnArxivOperations.conflict_filters', ['acquisition_source.source']):
TestRecordMetadata.create_from_file(
__name__, 'merge_record_arxiv.json', index_name='records-hep')
update_workflow_id = build_workflow(RECORD_WITH_CONFLICTS).id
# By default the root is {}.
eng_uuid = start('article', object_id=update_workflow_id)
eng = WorkflowEngine.from_uuid(eng_uuid)
obj = eng.objects[0]
conflicts = obj.extra_data.get('conflicts')
assert obj.status == ObjectStatus.HALTED
assert len(conflicts) == 1
assert obj.extra_data.get('callback_url') is not None
assert obj.extra_data.get('is-update') is True
assert obj.extra_data['merger_root'] == RECORD_WITH_CONFLICTS
assert obj.extra_data['merger_head_revision'] == 0
assert obj.extra_data['merger_original_root'] == {}
示例3: test_delete_work_cache_putcode_nonexisting
def test_delete_work_cache_putcode_nonexisting(self):
self.recid = '000000'
TestRecordMetadata.create_from_kwargs(
json={'control_number': self.recid, 'deleted': True})
self.cache.write_work_putcode('51391229')
pusher = domain_models.OrcidPusher(self.orcid, self.recid, self.oauth_token)
assert not pusher.push()
示例4: test_get_signatures_matching_a_phonetic_encoding
def test_get_signatures_matching_a_phonetic_encoding(isolated_app):
TestRecordMetadata.create_from_file(__name__, '8201.json', index_name='records-hep')
TestRecordMetadata.create_from_file(__name__, '1518353.json', index_name='records-hep')
expected = [
{
'author_affiliation': 'SUNY, Stony Brook',
'author_id': None,
'author_name': 'Rho, Mannque',
'publication_id': 8201,
'signature_block': 'Rm',
'signature_uuid': 'fe4220bf-7c57-4191-8d0c-6e791e84c505',
},
{
'author_affiliation': '',
'author_id': None,
'author_name': 'Rao, Mayuri Sathyanarayana',
'publication_id': 1518353,
'signature_block': 'Rm',
'signature_uuid': '383d97f4-5213-4735-9c7d-0d1cf992cce7',
},
]
result = list(get_signatures_matching_a_phonetic_encoding('Rm'))
assert sorted(expected) == sorted(result)
示例5: test_match_reference_on_texkey
def test_match_reference_on_texkey(isolated_app):
cited_record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'_collections': ['Literature'],
'control_number': 1,
'document_type': ['article'],
'texkeys': [
'Giudice:2007fh',
],
'titles': [
{
'title': 'The Strongly-Interacting Light Higgs'
}
],
}
TestRecordMetadata.create_from_kwargs(
json=cited_record_json, index_name='records-hep')
reference = {
'reference': {
'texkey': 'Giudice:2007fh',
}
}
schema = load_schema('hep')
subschema = schema['properties']['references']
assert validate([reference], subschema) is None
reference = match_reference(reference)
assert reference['record']['$ref'] == 'http://localhost:5000/api/literature/1'
assert validate([reference], subschema) is None
示例6: test_match_reference_doesnt_touch_curated
def test_match_reference_doesnt_touch_curated(isolated_app):
cited_record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'_collections': ['Literature'],
'control_number': 1,
'document_type': ['article'],
'dois': [{
'value': '10.1371/journal.pone.0188398',
}],
}
TestRecordMetadata.create_from_kwargs(
json=cited_record_json, index_name='records-hep')
reference = {
'curated_relation': True,
'record': {
'$ref': 'http://localhost:5000/api/literature/42',
},
'reference': {
'dois': ['10.1371/journal.pone.0188398'],
}
}
schema = load_schema('hep')
subschema = schema['properties']['references']
assert validate([reference], subschema) is None
reference = match_reference(reference)
assert reference['record']['$ref'] == 'http://localhost:5000/api/literature/42'
示例7: test_jinja_template_with_one_author
def test_jinja_template_with_one_author(isolated_api_client):
record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'control_number': '64209',
'texkeys': [
'a123bx'
],
'titles': [
{
'title': 'The Amazing Spiderman',
},
],
'authors': [
{
'full_name': 'Lee, Stan',
},
],
'collaborations': [{
'value': 'LHCb',
}],
'dois': [
{
'value': '10.1088/1361-6633/aa5514',
},
],
'arxiv_eprints': [
{
'value': '1607.06746',
'categories': ['hep-th']
},
],
'publication_info': [{
'journal_title': 'Phys.Rev.A',
'journal_volume': '58',
'journal_issue': '120',
'artid': '17920',
'year': '2014'
}],
'report_numbers': [{
'value': 'DESY-17-036'
}]
}
TestRecordMetadata.create_from_kwargs(
json=record_json, index_name='records-hep')
response = isolated_api_client.get(
'/literature/64209',
headers={'Accept': 'application/vnd+inspire.latex.eu+x-latex'}
)
expected = """\
%\\cite{a123bx}
\\bibitem{a123bx}
S.~Lee [LHCb],
%``The Amazing Spiderman,''
Phys.\\ Rev.\\ A \\textbf{58} (2014) no.120, 17920
doi:10.1088/1361-6633/aa5514
[arXiv:1607.06746 [hep-th]]."""
result = response.data
assert dedent(expected) == result
示例8: test_save_sampled_signature_pairs
def test_save_sampled_signature_pairs(isolated_app, tmpdir):
TestRecordMetadata.create_from_file(__name__, '765515.json')
TestRecordMetadata.create_from_file(__name__, '765975.json')
curated_signatures_fd = tmpdir.join('curated_signatures.jsonl')
input_clusters_fd = tmpdir.join('input_clusters.jsonl')
sampled_pairs_fd = tmpdir.join('sampled_pairs.jsonl')
config = {
'DISAMBIGUATION_CURATED_SIGNATURES_PATH': str(curated_signatures_fd),
'DISAMBIGUATION_INPUT_CLUSTERS_PATH': str(input_clusters_fd),
'DISAMBIGUATION_SAMPLED_PAIRS_PATH': str(sampled_pairs_fd),
'DISAMBIGUATION_SAMPLED_PAIRS_SIZE': 12 * 100,
}
with patch.dict(current_app.config, config):
save_curated_signatures_and_input_clusters()
save_sampled_pairs()
sampled_pairs = [json.loads(line) for line in sampled_pairs_fd.readlines()]
normalized_sampled_pairs = [
{
'same_cluster': sampled_pair['same_cluster'],
'signature_uuids': sorted(sampled_pair['signature_uuids']),
} for sampled_pair in sampled_pairs
] # XXX: so that the assertion doesn't depend on signature order.
assert {
'same_cluster': True,
'signature_uuids': [
'cbf081db-fcb7-4386-baaf-f30636debfa7',
'd08e1eb7-fa1b-4ea0-8917-5b3de969c582',
],
} in normalized_sampled_pairs
示例9: test_get_all_publications
def test_get_all_publications():
TestRecordMetadata.create_from_file(__name__, '792017.json')
expected = {
'abstract': 'This talk describes past progress in probing the structure of matter and the content of the Universe, which has led to the Standard Model of elementary particles, and the prospects for establishing new physics beyond the Standard Model using the LHC particle collider at CERN.',
'authors': ['Ellis, John R.'],
'collaborations': [],
'keywords': [
'29.20.Db',
'98.80.-k',
'12.60.-i',
'elementary particles',
'standard model',
'cosmology',
'particle accelerators',
'Elementary particles',
'Beyond the Standard Model',
'Colliders',
'Large Hadron Collider',
'Standard Model',
],
'publication_id': 792017,
'title': 'The quest for elementary particles',
'topics': ['Phenomenology-HEP'],
}
result = list(get_all_publications())
assert expected in result
示例10: test_train_and_save_distance_model
def test_train_and_save_distance_model(isolated_app, tmpdir):
TestRecordMetadata.create_from_file(__name__, '765515.json')
TestRecordMetadata.create_from_file(__name__, '765975.json')
curated_signatures_fd = tmpdir.join('curated_signatures.jsonl')
sampled_pairs_fd = tmpdir.join('sampled_pairs.jsonl')
publications_fd = tmpdir.join('publications.jsonl')
ethnicity_data_fd = tmpdir.join('ethnicity.csv')
ethnicity_data_fd.write(ETHNICITY_TRAINING_DATA)
ethnicity_model_fd = tmpdir.join('ethnicity.pkl')
distance_model_fd = tmpdir.join('distance.pkl')
config = {
'DISAMBIGUATION_CURATED_SIGNATURES_PATH': str(curated_signatures_fd),
'DISAMBIGUATION_SAMPLED_PAIRS_PATH': str(sampled_pairs_fd),
'DISAMBIGUATION_SAMPLED_PAIRS_SIZE': 12 * 100,
'DISAMBIGUATION_PUBLICATIONS_PATH': str(publications_fd),
'DISAMBIGUATION_ETHNICITY_DATA_PATH': str(ethnicity_data_fd),
'DISAMBIGUATION_ETHNICITY_MODEL_PATH': str(ethnicity_model_fd),
'DISAMBIGUATION_DISTANCE_MODEL_PATH': str(distance_model_fd)
}
with patch.dict(current_app.config, config):
save_curated_signatures_and_input_clusters()
save_sampled_pairs()
save_publications()
train_and_save_ethnicity_model()
train_and_save_distance_model()
ethnicity_estimator = EthnicityEstimator()
ethnicity_estimator.load_model(str(ethnicity_model_fd))
distance_estimator = DistanceEstimator(ethnicity_estimator)
distance_estimator.load_model(str(distance_model_fd))
示例11: test_save_publications
def test_save_publications(isolated_app, tmpdir):
TestRecordMetadata.create_from_file(__name__, '792017.json')
publications_fd = tmpdir.join('publications.jsonl')
config = {'DISAMBIGUATION_PUBLICATIONS_PATH': str(publications_fd)}
with patch.dict(current_app.config, config):
save_publications()
publications = [json.loads(line) for line in publications_fd.readlines()]
assert {
'abstract': 'This talk describes past progress in probing the structure of matter and the content of the Universe, which has led to the Standard Model of elementary particles, and the prospects for establishing new physics beyond the Standard Model using the LHC particle collider at CERN.',
'authors': ['Ellis, John R.'],
'collaborations': [],
'keywords': [
'29.20.Db',
'98.80.-k',
'12.60.-i',
'elementary particles',
'standard model',
'cosmology',
'particle accelerators',
'Elementary particles',
'Beyond the Standard Model',
'Colliders',
'Large Hadron Collider',
'Standard Model',
],
'publication_id': 792017,
'title': 'The quest for elementary particles',
'topics': ['Phenomenology-HEP'],
} in publications
示例12: test_match_reference_for_data_config
def test_match_reference_for_data_config(isolated_app):
"""Test reference matcher for the JCAP and JHEP configuration"""
cited_record_json = {
'$schema': 'http://localhost:5000/schemas/records/data.json',
'_collections': ['Data'],
'control_number': 1,
'dois': [
{
'value': '10.5281/zenodo.11020'
}
],
}
TestRecordMetadata.create_from_kwargs(
json=cited_record_json, index_name='records-data', pid_type='dat')
reference = {
'reference': {
'dois': [
'10.5281/zenodo.11020'
],
'publication_info': {
'year': 2007
}
}
}
reference = match_reference(reference)
assert reference['record']['$ref'] == 'http://localhost:5000/api/data/1'
示例13: test_jinja_template_with_collaborations_and_no_authors
def test_jinja_template_with_collaborations_and_no_authors(isolated_api_client):
record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'control_number': '64209',
'texkeys': [
'a123bx'
],
'titles': [
{
'title': 'Physics',
},
],
'collaborations': [{
'value': 'LHCb',
}]
}
TestRecordMetadata.create_from_kwargs(
json=record_json, index_name='records-hep')
response = isolated_api_client.get(
'/literature/64209',
headers={'Accept': 'application/vnd+inspire.latex.eu+x-latex'}
)
expected = """\
%\\cite{a123bx}
\\bibitem{a123bx}
[LHCb],
%``Physics,''"""
result = response.data
assert dedent(expected) == result
示例14: test_match_reference_ignores_hidden_collections
def test_match_reference_ignores_hidden_collections(isolated_app):
cited_record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'_collections': ['HAL Hidden'],
'control_number': 1,
'document_type': ['article'],
'dois': [{
'value': '10.1371/journal.pone.0188398',
}],
}
TestRecordMetadata.create_from_kwargs(
json=cited_record_json, index_name='records-hep')
reference = {
'reference': {
'dois': ['10.1371/journal.pone.0188398'],
}
}
schema = load_schema('hep')
subschema = schema['properties']['references']
assert validate([reference], subschema) is None
reference = match_reference(reference)
assert 'record' not in reference
示例15: test_jinja_template_uses_report_number_without_doi_and_arxiv_eprint
def test_jinja_template_uses_report_number_without_doi_and_arxiv_eprint(isolated_api_client):
record_json = {
'$schema': 'http://localhost:5000/schemas/records/hep.json',
'control_number': '64209',
'texkeys': [
'a123bx'
],
'titles': [
{
'title': 'Physics',
},
],
'report_numbers': [{
'value': 'DESY-17-036'
}]
}
TestRecordMetadata.create_from_kwargs(
json=record_json, index_name='records-hep')
response = isolated_api_client.get(
'/literature/64209',
headers={'Accept': 'application/vnd+inspire.latex.eu+x-latex'}
)
expected = """\
%\\cite{a123bx}
\\bibitem{a123bx}
%``Physics,''
DESY-17-036."""
result = response.data
assert dedent(expected) == result