コード例 #1
0
def test_get_head_source_return_arxiv_when_one_arxive_source_present(app, simple_record):
    # XXX: for some reason, this must be internal.
    from inspirehep.modules.migrator.tasks import record_insert_or_replace

    rec = record_insert_or_replace(simple_record)
    uuid = rec.id

    # two sources for the same record
    insert_wf_record_source(json=simple_record, record_uuid=uuid, source='ejl')

    assert get_head_source(uuid) == 'publisher'

    insert_wf_record_source(json=simple_record, record_uuid=uuid, source='arxiv')
    assert get_head_source(uuid) == 'arxiv'
コード例 #2
0
def test_get_head_source_return_arxiv_when_one_arxive_source_present(
        app, simple_record):
    # XXX: for some reason, this must be internal.
    from inspirehep.modules.migrator.tasks import record_insert_or_replace

    rec = record_insert_or_replace(simple_record)
    uuid = rec.id

    # two sources for the same record
    insert_wf_record_source(json=simple_record, record_uuid=uuid, source='ejl')

    assert get_head_source(uuid) == 'publisher'

    insert_wf_record_source(json=simple_record,
                            record_uuid=uuid,
                            source='arxiv')
    assert get_head_source(uuid) == 'arxiv'
コード例 #3
0
def test_get_head_source_return_arxiv_when_one_arxive_source_present(
        app, simple_record):
    # XXX: for some reason, this must be internal.
    from inspirehep.modules.records.api import InspireRecord

    rec = InspireRecord.create_or_update(simple_record)
    rec.commit()
    uuid = rec.id

    # two sources for the same record
    insert_wf_record_source(json=simple_record, record_uuid=uuid, source='ejl')

    assert get_head_source(uuid) == 'publisher'

    insert_wf_record_source(json=simple_record,
                            record_uuid=uuid,
                            source='arxiv')
    assert get_head_source(uuid) == 'arxiv'
コード例 #4
0
def start_merger(head_id, update_id, current_user_id=None):
    """Start a new ManualMerge workflow to merge two records manually.

    Args:
        head_id: the id of the first record to merge. This record is the one
            that will be updated with the new information.
        update_id: the id of the second record to merge. This record is the
            one that is going to be deleted and replaced by `head`.
        current_user_id: Id of the current user provided by the Flask app.

    Returns:
        (int): the current workflow object's id.
    """
    data = {
        'pid_type': 'lit',  # TODO: support
        'recid_head': head_id,
        'recid_update': update_id,
    }

    head = get_db_record('lit', head_id)
    update = get_db_record('lit', update_id)

    workflow_object = workflow_object_class.create(data=None,
                                                   id_user=current_user_id,
                                                   data_type='hep')

    wf_id = workflow_object.id  # to retrieve it later
    workflow_object.extra_data.update(data)

    # preparing identifiers in order to do less requests possible later
    head_source = get_head_source(head.id) or merger_get_source(head)

    update_source = get_source(update)
    update_source = update_source if update_source else 'arxiv'

    workflow_object.extra_data['head_source'] = head_source.lower()
    workflow_object.extra_data['update_source'] = update_source.lower()

    workflow_object.extra_data['head_control_number'] = head_id
    workflow_object.extra_data['update_control_number'] = update_id

    workflow_object.extra_data['head_uuid'] = str(head.id)
    workflow_object.extra_data['update_uuid'] = str(update.id)

    workflow_object.extra_data['head'] = head
    workflow_object.extra_data['update'] = update

    workflow_object.save()

    start('manual_merge', object_id=wf_id)

    return wf_id
コード例 #5
0
def test_get_head_source_no_rec_on_the_db_gives_none(app):
    assert get_head_source('7753a30b-1111-2222-3333-d5020069b3ab') is None
コード例 #6
0
def test_get_head_source_no_rec_on_the_db_gives_none(app):
    assert get_head_source('7753a30b-1111-2222-3333-d5020069b3ab') is None