Example #1
0
def test_save_roots(workflow_app):

    head = InspireRecord.create_or_update(fake_record('title1', 123),
                                          skip_files=False)
    head.commit()
    update = InspireRecord.create_or_update(fake_record('title2', 456),
                                            skip_files=False)
    update.commit()

    obj = workflow_object_class.create(data={}, data_type='hep')
    obj.extra_data['head_uuid'] = str(head.id)
    obj.extra_data['update_uuid'] = str(update.id)
    obj.save()

    insert_wf_record_source(json={}, record_uuid=head.id, source='a')
    insert_wf_record_source(json={}, record_uuid=head.id, source='b')

    # this will not be saved because there's already an entry with source `a`
    insert_wf_record_source(json={}, record_uuid=update.id, source='a')
    insert_wf_record_source(json={}, record_uuid=update.id, source='c')

    save_roots(obj, None)

    assert read_wf_record_source(str(head.id), 'a')
    assert read_wf_record_source(str(head.id), 'b')
    assert read_wf_record_source(str(head.id), 'c')
def test_save_roots(workflow_app):

    head = InspireRecord.create_or_update(fake_record('title1', 123), skip_files=False)
    head.commit()
    update = InspireRecord.create_or_update(fake_record('title2', 456), skip_files=False)
    update.commit()

    obj = workflow_object_class.create(
        data={},
        data_type='hep'
    )
    obj.extra_data['head_uuid'] = str(head.id)
    obj.extra_data['update_uuid'] = str(update.id)
    obj.save()

    # Union: keep the most recently created/updated root from each source.
    insert_wf_record_source(json={'version': 'original'}, record_uuid=head.id, source='arxiv')

    insert_wf_record_source(json={'version': 'updated'}, record_uuid=update.id, source='arxiv')

    insert_wf_record_source(json={'version': 'updated'}, record_uuid=update.id, source='publisher')

    save_roots(obj, None)

    arxiv_rec = read_wf_record_source(head.id, 'arxiv')
    assert arxiv_rec.json == {'version': 'updated'}

    pub_rec = read_wf_record_source(head.id, 'publisher')
    assert pub_rec.json == {'version': 'updated'}

    assert not read_wf_record_source(update.id, 'arxiv')
    assert not read_wf_record_source(update.id, 'publisher')
def test_save_roots(workflow_app):
    # XXX: for some reason, this must be internal.
    from inspirehep.modules.migrator.tasks import record_insert_or_replace

    head = record_insert_or_replace(fake_record('title1', 123))
    update = record_insert_or_replace(fake_record('title2', 456))

    obj = workflow_object_class.create(
        data={},
        data_type='hep'
    )
    obj.extra_data['head_uuid'] = str(head.id)
    obj.extra_data['update_uuid'] = str(update.id)
    obj.save()

    insert_wf_record_source(json={}, record_uuid=head.id, source='a')
    insert_wf_record_source(json={}, record_uuid=head.id, source='b')

    # this will not be saved because there's already an entry with source `a`
    insert_wf_record_source(json={}, record_uuid=update.id, source='a')
    insert_wf_record_source(json={}, record_uuid=update.id, source='c')

    save_roots(obj, None)

    assert read_wf_record_source(str(head.id), 'a')
    assert read_wf_record_source(str(head.id), 'b')
    assert read_wf_record_source(str(head.id), 'c')
Example #4
0
def test_save_roots(workflow_app):

    head = InspireRecord.create_or_update(fake_record('title1', 123),
                                          skip_files=False)
    head.commit()
    update = InspireRecord.create_or_update(fake_record('title2', 456),
                                            skip_files=False)
    update.commit()

    obj = workflow_object_class.create(data={}, data_type='hep')
    obj.extra_data['head_uuid'] = str(head.id)
    obj.extra_data['update_uuid'] = str(update.id)
    obj.save()

    # Union: keep the most recently created/updated root from each source.
    insert_wf_record_source(json={'version': 'original'},
                            record_uuid=head.id,
                            source='arxiv')

    insert_wf_record_source(json={'version': 'updated'},
                            record_uuid=update.id,
                            source='arxiv')

    insert_wf_record_source(json={'version': 'updated'},
                            record_uuid=update.id,
                            source='publisher')

    save_roots(obj, None)

    arxiv_rec = read_wf_record_source(head.id, 'arxiv')
    assert arxiv_rec.json == {'version': 'updated'}

    pub_rec = read_wf_record_source(head.id, 'publisher')
    assert pub_rec.json == {'version': 'updated'}

    assert not read_wf_record_source(update.id, 'arxiv')
    assert not read_wf_record_source(update.id, 'publisher')
def test_save_roots(workflow_app):
    # XXX: for some reason, this must be internal.
    from inspirehep.modules.migrator.tasks import record_insert_or_replace

    head = record_insert_or_replace(fake_record('title1', 123))
    update = record_insert_or_replace(fake_record('title2', 456))

    obj = workflow_object_class.create(data={}, data_type='hep')
    obj.extra_data['head_uuid'] = str(head.id)
    obj.extra_data['update_uuid'] = str(update.id)
    obj.save()

    insert_wf_record_source(json={}, record_uuid=head.id, source='a')
    insert_wf_record_source(json={}, record_uuid=head.id, source='b')

    # this will not be saved because there's already an entry with source `a`
    insert_wf_record_source(json={}, record_uuid=update.id, source='a')
    insert_wf_record_source(json={}, record_uuid=update.id, source='c')

    save_roots(obj, None)

    assert read_wf_record_source(str(head.id), 'a')
    assert read_wf_record_source(str(head.id), 'b')
    assert read_wf_record_source(str(head.id), 'c')