Пример #1
0
def test_has_same_source(app, simple_record):
    obj = workflow_object_class.create(
        data=simple_record,
        status=ObjectStatus.HALTED,
        data_type='hep',
    )
    obj_id = obj.id
    obj.save()
    es.indices.refresh('holdingpen-hep')

    obj2 = WorkflowObject.create(data=simple_record, data_type='hep')
    match_non_completed_wf_in_holdingpen(obj2, None)

    same_source_func = has_same_source('holdingpen_matches')

    assert same_source_func(obj2, None)
    assert obj2.extra_data['holdingpen_matches'] == [obj_id]

    # change source and match the wf in the holdingpen
    different_source_rec = dict(simple_record)
    different_source_rec['acquisition_source'] = {'source': 'different'}
    obj3 = WorkflowObject.create(data=different_source_rec, data_type='hep')

    assert match_non_completed_wf_in_holdingpen(obj3, None)
    assert not same_source_func(obj3, None)
Пример #2
0
def test_has_same_source(app, simple_record):
    obj = workflow_object_class.create(
        data=simple_record,
        status=ObjectStatus.HALTED,
        data_type='hep',
    )
    obj_id = obj.id
    obj.save()
    es.indices.refresh('holdingpen-hep')

    obj2 = WorkflowObject.create(data=simple_record, data_type='hep')
    match_non_completed_wf_in_holdingpen(obj2, None)

    same_source_func = has_same_source('holdingpen_matches')

    assert same_source_func(obj2, None)
    assert obj2.extra_data['holdingpen_matches'] == [obj_id]

    # change source and match the wf in the holdingpen
    different_source_rec = dict(simple_record)
    different_source_rec['acquisition_source'] = {'source': 'different'}
    obj3 = WorkflowObject.create(data=different_source_rec, data_type='hep')

    assert match_non_completed_wf_in_holdingpen(obj3, None)
    assert not same_source_func(obj3, None)
Пример #3
0
    mark('unexpected-workflow-path', True),
    error_workflow('Unexpected workflow path.'),
    save_workflow,
]


# Currently we handle harvests as if all were arxiv, that will have to change.
PROCESS_HOLDINGPEN_MATCH_HARVEST = [
    IF_NOT(
        is_marked('is-update'),
        IF(
            is_marked('previously_rejected'),
            IF_NOT(
                is_marked('auto-approved'),
                IF(
                    has_same_source('previously_rejected_matches'),
                    [
                        mark('approved', False),  # auto-reject
                        save_workflow,
                        stop_processing,
                    ],
                )
            ),
        ),
    ),

    IF_ELSE(
        is_marked('already-in-holding-pen'),
        IF_ELSE(
            has_same_source('holdingpen_matches'),
            # stop the matched wf and continue this one
Пример #4
0
ERROR_WITH_UNEXPECTED_WORKFLOW_PATH = [
    mark('unexpected-workflow-path', True),
    error_workflow('Unexpected workflow path.'),
    save_workflow,
]


# Currently we handle harvests as if all were arxiv, that will have to change.
PROCESS_HOLDINGPEN_MATCH_HARVEST = [
    IF_NOT(
        is_marked('is-update'),
        IF(
            is_marked('previously_rejected'),
            IF(
                has_same_source('previously_rejected_matches'),
                [
                    mark('approved', False),  # auto-reject
                    save_workflow,
                    stop_processing,
                ],
            )
        ),
    ),

    IF_ELSE(
        is_marked('already-in-holding-pen'),
        IF_ELSE(
            has_same_source('holdingpen_matches'),
            # stop the matched wf and continue this one
            [