当前位置: 首页>>代码示例>>Python>>正文


Python TestRecordMetadata.create_from_kwargs方法代码示例

本文整理汇总了Python中factories.db.invenio_records.TestRecordMetadata.create_from_kwargs方法的典型用法代码示例。如果您正苦于以下问题:Python TestRecordMetadata.create_from_kwargs方法的具体用法?Python TestRecordMetadata.create_from_kwargs怎么用?Python TestRecordMetadata.create_from_kwargs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在factories.db.invenio_records.TestRecordMetadata的用法示例。


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

示例1: test_match_reference_ignores_hidden_collections

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:29,代码来源:test_refextract_matcher.py

示例2: test_jinja_template_with_collaborations_and_no_authors

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:34,代码来源:test_records_serializers_latex.py

示例3: test_jinja_template_with_one_author

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:62,代码来源:test_records_serializers_latex.py

示例4: test_jinja_template_prints_citation_count

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:29,代码来源:test_records_serializers_latex.py

示例5: test_delete_work_cache_putcode_nonexisting

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
 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()
开发者ID:harunurhan,项目名称:inspire-next,代码行数:9,代码来源:test_orcid_domain_models.py

示例6: test_match_reference_on_texkey

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:35,代码来源:test_refextract_matcher.py

示例7: test_jinja_template_uses_report_number_without_doi_and_arxiv_eprint

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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
开发者ID:harunurhan,项目名称:inspire-next,代码行数:34,代码来源:test_records_serializers_latex.py

示例8: test_match_reference_for_data_config

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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'
开发者ID:harunurhan,项目名称:inspire-next,代码行数:33,代码来源:test_refextract_matcher.py

示例9: test_match_reference_doesnt_touch_curated

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
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'
开发者ID:harunurhan,项目名称:inspire-next,代码行数:33,代码来源:test_refextract_matcher.py

示例10: test_refextract_from_pdf

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
def test_refextract_from_pdf(
    mocked_indexing_task,
    mocked_api_request_magpie,
    mocked_api_request_beard,
    mocked_is_pdf_link,
    mocked_package_download,
    mocked_arxiv_download,
    workflow_app,
    mocked_external_services
):
    """Test refextract from PDF and reference matching for default Configuration
     by going through the entire workflow."""

    cited_record_json = {
        '$schema': 'http://localhost:5000/schemas/records/hep.json',
        '_collections': ['Literature'],
        'arxiv_eprints': [
            {
                'categories': ['quant-ph', 'cond-mat.mes-hall', 'cond-mat.str-el', 'math-ph', 'math.MP'],
                'value': '1308.0815'
            }
        ],
        'control_number': 1000,
        'document_type': ['article'],
        'titles': [
            {
                'source': 'arXiv',
                'title': 'Solving a two-electron quantum dot model in terms of polynomial solutions of a Biconfluent Heun equation'
            }
        ],
    }

    TestRecordMetadata.create_from_kwargs(
        json=cited_record_json, index='records-hep', pid_type='lit')
    citing_record, categories = insert_citing_record()

    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
        "MAGPIE_API_URL": "http://example.com/magpie",
        'ARXIV_CATEGORIES': categories,
    }

    schema = load_schema('hep')
    subschema = schema['properties']['acquisition_source']

    assert validate(citing_record['acquisition_source'], subschema) is None

    with mock.patch.dict(workflow_app.config, extra_config):
        workflow_id = build_workflow(citing_record).id
        citing_doc_workflow_uuid = start('article', object_id=workflow_id)

    citing_doc_eng = WorkflowEngine.from_uuid(citing_doc_workflow_uuid)
    citing_doc_obj = citing_doc_eng.processed_objects[0]

    assert citing_doc_obj.data['references'][7]['record']['$ref'] == 'http://localhost:5000/api/literature/1000'
    assert citing_doc_obj.data['references'][0]['raw_refs'][0]['source'] == 'arXiv'
开发者ID:harunurhan,项目名称:inspire-next,代码行数:58,代码来源:test_workflows_tasks_actions.py

示例11: test_delete_work_force_delete

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
    def test_delete_work_force_delete(self):
        self.recid = '99'
        TestRecordMetadata.create_from_kwargs(
            json={'control_number': self.recid,
                  'deleted': False,
                  '_private_notes': [{'value': 'orcid-push-force-delete'}]})
        self.cache.write_work_putcode('51391229')

        pusher = domain_models.OrcidPusher(self.orcid, self.recid, self.oauth_token)
        assert not pusher.push()
开发者ID:harunurhan,项目名称:inspire-next,代码行数:12,代码来源:test_orcid_domain_models.py

示例12: test_doubled_citations_should_not_count_to_citation_count

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
def test_doubled_citations_should_not_count_to_citation_count(isolated_app):
    record_json = {
        'control_number': 321,
    }
    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)
    TestRecordMetadata.create_from_kwargs(json=ref, disable_persistent_identifier=True)

    assert record_1.get_citations_count(show_duplicates=True) == 2
    assert record_1.get_citations_count() == 1
开发者ID:inspirehep,项目名称:inspire-next,代码行数:14,代码来源:test_records_api.py

示例13: test_get_linked_refs

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
def test_get_linked_refs(isolated_api_client):
    cited_record_json = {
        '$schema': 'http://localhost:5000/schemas/records/hep.json',
        '_collections': ['Literature'],
        'control_number': 1,
        'document_type': ['article'],
        'publication_info': [
            {
                'artid': '045',
                'journal_title': 'JHEP',
                'journal_volume': '06',
                'page_start': '045',
                'year': 2007
            }
        ],
        'titles': [
            {
                'title': 'The Strongly-Interacting Light Higgs'
            }
        ],
    }

    TestRecordMetadata.create_from_kwargs(
        json=cited_record_json, index_name='records-hep')

    references = {
        'references': [
            {
                'reference': {
                    'publication_info': {
                        'artid': '045',
                        'journal_title': 'JHEP',
                        'journal_volume': '06',
                        'page_start': '045',
                        'year': 2007
                    }
                }
            }
        ]
    }

    response = isolated_api_client.post(
        '/editor/linked_references/',
        content_type='application/json',
        data=json.dumps(references),
    )
    assert response.status_code == 200

    linked_refs = json.loads(response.data)
    assert linked_refs['references'][0]['record']['$ref'] == 'http://localhost:5000/api/literature/1'
开发者ID:harunurhan,项目名称:inspire-next,代码行数:52,代码来源:test_editor_views.py

示例14: test_store_root_new_record

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
def test_store_root_new_record(workflow_app):
    config = {
        'FEATURE_FLAG_ENABLE_MERGER': True
    }
    eng = MagicMock(workflow_definition=MagicMock(data_type='hep'))

    with patch.dict(current_app.config, config):
        head = TestRecordMetadata.create_from_kwargs(index=False, has_pid=False)
        head_uuid = head.record_metadata.id
        record = head.record_metadata.json

        obj = workflow_object_class.create(record)

        root = {
            'version': 'original',
            'acquisition_source': {'source': 'arXiv'}
        }

        extra_data = {
            'head_uuid': str(head_uuid),
            'merger_root': root,
        }

        obj.extra_data = extra_data

        store_root(obj, eng)

        root_entry = read_wf_record_source(head_uuid, 'arxiv')

        assert root_entry.json == root
开发者ID:harunurhan,项目名称:inspire-next,代码行数:32,代码来源:test_workflows_tasks_upload.py

示例15: test_responses_with_etag

# 需要导入模块: from factories.db.invenio_records import TestRecordMetadata [as 别名]
# 或者: from factories.db.invenio_records.TestRecordMetadata import create_from_kwargs [as 别名]
def test_responses_with_etag(workflow_app):

    factory = TestRecordMetadata.create_from_kwargs(
        json={'titles': [{'title': 'Etag version'}]}
    )

    workflow_id = build_workflow(factory.record_metadata.json).id
    obj = workflow_object_class.get(workflow_id)
    obj.save()
    db.session.commit()

    workflow_url = '/api/holdingpen/{}'.format(obj.id)

    with workflow_app.test_client() as client:
        login_user_via_session(client, email='[email protected]')
        response = client.get(workflow_url)
        assert response.status_code == 200

        etag = response.headers['ETag']
        last_modified = response.headers['Last-Modified']

        response = client.get(
            workflow_url, headers={'If-Modified-Since': last_modified})
        assert response.status_code == 304

        response = client.get(workflow_url, headers={'If-None-Match': etag})
        assert response.status_code == 304

        response = client.get(workflow_url, headers={'If-None-Match': 'Jessica Jones'})
        assert response.status_code == 200
开发者ID:inspirehep,项目名称:inspire-next,代码行数:32,代码来源:test_views.py


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