def test_harvesting_arxiv_workflow_manual_rejected( mocked_arxiv_download, mocked_refextract_extract_refs, mocked_api_request_magpie, mocked_api_request_beard, workflow_app, mocked_external_services, ): """Test a full harvesting workflow.""" record = generate_record() extra_config = { "BEARD_API_URL": "http://example.com/beard", "MAGPIE_API_URL": "http://example.com/magpie", } workflow_uuid, eng, obj = get_halted_workflow( app=workflow_app, extra_config=extra_config, record=record, ) obj.extra_data["approved"] = False obj.save() db.session.commit() eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] obj_id = obj.id obj.continue_workflow() obj = workflow_object_class.get(obj_id) # It was rejected assert obj.status == ObjectStatus.COMPLETED
def test_harvesting_arxiv_workflow_manual_rejected( mocked_arxiv_download, mocked_refextract_extract_refs, mocked_api_request_magpie, mocked_api_request_beard, mocked_package_download, workflow_app, mocked_external_services, ): """Test a full harvesting workflow.""" record = generate_record() extra_config = { "BEARD_API_URL": "http://example.com/beard", "MAGPIE_API_URL": "http://example.com/magpie", } workflow_uuid, eng, obj = get_halted_workflow( app=workflow_app, extra_config=extra_config, record=record, ) obj.extra_data["approved"] = False obj.save() db.session.commit() eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] obj_id = obj.id obj.continue_workflow() obj = workflow_object_class.get(obj_id) # It was rejected assert obj.status == ObjectStatus.COMPLETED
def test_harvesting_arxiv_workflow_manual_accepted( mocked_refextract_extract_refs, mocked_matching_search, mocked_api_request_magpie, mocked_api_request_beard, mocked_download_utils, mocked_download_arxiv, workflow_app, ): record = generate_record() """Test a full harvesting workflow.""" with requests_mock.Mocker() as requests_mocker: requests_mocker.register_uri( requests_mock.ANY, re.compile('.*(indexer|localhost).*'), real_http=True, ) requests_mocker.register_uri( 'POST', re.compile('https?://localhost:1234.*', ), text=u'[INFO]', status_code=200, ) workflow_uuid, eng, obj = get_halted_workflow( app=workflow_app, extra_config={'PRODUCTION_MODE': False}, record=record, ) do_accept_core( app=workflow_app, workflow_id=obj.id, ) eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] assert obj.status == ObjectStatus.WAITING response = do_robotupload_callback( app=workflow_app, workflow_id=obj.id, recids=[12345], ) assert response.status_code == 200 obj = workflow_object_class.get(obj.id) assert obj.status == ObjectStatus.WAITING response = do_webcoll_callback(app=workflow_app, recids=[12345]) assert response.status_code == 200 eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] # It was accepted assert obj.status == ObjectStatus.COMPLETED
def test_harvesting_arxiv_workflow_manual_accepted( mocked_refextract_extract_refs, mocked_matching_match, mocked_api_request_magpie, mocked_api_request_beard, mocked_download_utils, mocked_download_arxiv, mocked_package_download, workflow_app, mocked_external_services, ): record = generate_record() """Test a full harvesting workflow.""" workflow_uuid, eng, obj = get_halted_workflow( app=workflow_app, record=record, ) do_accept_core( app=workflow_app, workflow_id=obj.id, ) eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] assert obj.status == ObjectStatus.WAITING response = do_robotupload_callback( app=workflow_app, workflow_id=obj.id, recids=[12345], ) assert response.status_code == 200 obj = workflow_object_class.get(obj.id) assert obj.status == ObjectStatus.WAITING response = do_webcoll_callback(app=workflow_app, recids=[12345]) assert response.status_code == 200 eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] # It was accepted assert obj.status == ObjectStatus.COMPLETED
def test_harvesting_arxiv_workflow_manual_accepted( mocked_refextract_extract_refs, mocked_matching_match, mocked_api_request_magpie, mocked_api_request_beard, mocked_download_utils, mocked_download_arxiv, workflow_app, mocked_external_services, ): record = generate_record() """Test a full harvesting workflow.""" workflow_uuid, eng, obj = get_halted_workflow( app=workflow_app, record=record, ) do_accept_core( app=workflow_app, workflow_id=obj.id, ) eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] assert obj.status == ObjectStatus.WAITING response = do_robotupload_callback( app=workflow_app, workflow_id=obj.id, recids=[12345], ) assert response.status_code == 200 obj = workflow_object_class.get(obj.id) assert obj.status == ObjectStatus.WAITING response = do_webcoll_callback(app=workflow_app, recids=[12345]) assert response.status_code == 200 eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] # It was accepted assert obj.status == ObjectStatus.COMPLETED
def test_harvesting_arxiv_workflow_manual_rejected( mocked_refextract_extract_refs, mocked_api_request_magpie, mocked_api_request_beard, mocked_download, small_app, ): """Test a full harvesting workflow.""" record = generate_record() extra_config = { "BEARD_API_URL": "http://example.com/beard", "MAGPIE_API_URL": "http://example.com/magpie", } workflow_uuid = None with small_app.app_context(): workflow_uuid, eng, obj = get_halted_workflow( app=small_app, extra_config=extra_config, record=record, ) # Now let's resolve it as accepted and continue # FIXME Should be accept, but record validation prevents us. obj.remove_action() obj.extra_data["approved"] = False # obj.extra_data["core"] = True obj.save() db.session.commit() eng = WorkflowEngine.from_uuid(workflow_uuid) obj = eng.processed_objects[0] obj_id = obj.id obj.continue_workflow() obj = workflow_object_class.get(obj_id) # It was rejected assert obj.status == ObjectStatus.COMPLETED