def test_datacite_register(dc_mock, app, db, es, minimal_record): # Create a reserved recid record = Record.create(minimal_record) record_uuid = record.id recid = record['recid'] recid_pid = PersistentIdentifier.create( 'recid', recid, status=PIDStatus.RESERVED) # Mint the record zenodo_record_minter(record_uuid, record) record.commit() db.session.commit() datacite_register(recid_pid.pid_value, str(record_uuid)) dc_mock().doi_post.assert_called_once_with( record['doi'], 'https://zenodo.org/record/{}'.format(recid))
def test_edit_flow(datacite_mock, api_client, db, es, location, json_auth_headers, deposit_url, get_json, auth_headers, json_headers, license_record, communities, resolver): """Test simple flow using REST API.""" headers = json_auth_headers client = api_client test_data = dict(metadata=dict( upload_type='presentation', title='Test title', creators=[ dict(name='Doe, John', affiliation='Atlantis'), dict(name='Smith, Jane', affiliation='Atlantis') ], description='Test Description', publication_date='2013-05-08', access_right='open', license='CC0-1.0', communities=[{ 'identifier': 'c1' }, { 'identifier': 'c3' }], )) # Create deposit response = client.post(deposit_url, data=json.dumps(test_data), headers=headers) data = get_json(response, code=201) # Get identifier and links current_search.flush_and_refresh(index='deposits') links = data['links'] # Upload 3 files for i in range(3): f = 'test{0}.txt'.format(i) response = client.post( links['files'], data=dict(file=(BytesIO(b'ctx'), f), name=f), headers=auth_headers, ) assert response.status_code == 201, i # Update metadata newdata = dict(metadata=data['metadata']) newdata['metadata']['title'] = 'Updated title' resdata = get_json(client.put(links['self'], data=json.dumps(newdata), headers=headers), code=200) # Publish deposition response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) record_id = data['record_id'] assert PersistentIdentifier.query.filter_by(pid_type='depid').count() == 1 # There should be two 'recid' PIDs - Concept PID and version PID assert PersistentIdentifier.query.filter_by(pid_type='recid').count() == 2 recid_pid = PersistentIdentifier.get('recid', str(record_id)) doi_pid = PersistentIdentifier.get(pid_type='doi', pid_value='10.5072/zenodo.1') assert doi_pid.status == PIDStatus.RESERVED # This task (datacite_register) would normally be executed asynchronously datacite_register(recid_pid.pid_value, recid_pid.object_uuid) assert doi_pid.status == PIDStatus.REGISTERED # Make sure it was registered properly in datacite # It should be called twice - for concept DOI and version DOI assert datacite_mock().metadata_post.call_count == 2 # Concept DOI call datacite_mock().doi_post.assert_any_call('10.5072/zenodo.1', 'https://zenodo.org/record/1') # Record DOI call datacite_mock().doi_post.assert_any_call('10.5072/zenodo.2', 'https://zenodo.org/record/2') # Does record exists? current_search.flush_and_refresh(index='records') preedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) expected_doi = '10.5072/zenodo.{0}'.format(record_id) assert preedit_data['doi'] == expected_doi # - community c3 got auto-accepted (owned by deposit user) assert preedit_data['metadata']['communities'] == [{'identifier': 'c3'}] # Are files downloadable by everyone (open)? assert len(preedit_data['files']) == 3 download_url = preedit_data['files'][0]['links']['download'] assert client.get(download_url).status_code == 200 # Edit record - can now be done immediately after. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 201 # Edit - 2nd time is invalid. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 403 # FIXME 400 # Get data data = get_json(client.get(links['self'], headers=auth_headers), code=200) # Not allowed to delete assert client.delete(links['self'], headers=auth_headers).status_code == 403 # Update metadata data = dict(metadata=data['metadata']) data['metadata'].update( dict(title='New title', access_right='closed', creators=[ dict(name="Smith, Jane", affiliation="Atlantis"), dict(name="Doe, John", affiliation="Atlantis"), ], communities=[{ 'identifier': 'c1' }])) resdata = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=200) assert resdata['title'] == 'New title' assert resdata['metadata']['title'] == 'New title' # Try to change DOI data['metadata']['doi'] = '10.1234/foo' data = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=400) # Approve community c = Community.get('c1') _, record = resolver.resolve(str(record_id)) c.accept_record(record) record.commit() db.session.commit() # Get record to confirm if both communities should be visible now assert get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200)['metadata']['communities'] == [ { 'identifier': 'c1' }, { 'identifier': 'c3' }, ] # Publish response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) current_search.flush_and_refresh(index='records') # - is record still accessible? postedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) # - sanity checks assert postedit_data['doi'] == expected_doi assert postedit_data['record_id'] == record_id # - files should no longer be downloadable (closed access) # - download_url worked before edit, so make sure it doesn't work now. assert 'files' not in postedit_data assert client.get(download_url).status_code == 404 # - c3 was removed, so only c1 one should be visible now assert postedit_data['metadata']['communities'] == [ { 'identifier': 'c1' }, ] # Edit data = get_json(client.post(links['edit'], headers=auth_headers), code=201) # Update data = dict(metadata=data['metadata']) data['metadata'].update(dict(title='Will be discarded')) resdata = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=200) # Discard data = get_json(client.post(links['discard'], headers=auth_headers), code=201) # Get and assert metadata data = get_json(client.get(links['self'], headers=auth_headers), code=200) assert data['title'] == postedit_data['title']
def test_edit_flow(mocker, api_client, db, es, location, json_auth_headers, deposit_url, get_json, auth_headers, json_headers, license_record, communities, resolver): """Test simple flow using REST API.""" datacite_mock = mocker.patch( 'invenio_pidstore.providers.datacite.DataCiteMDSClient') headers = json_auth_headers client = api_client test_data = dict( metadata=dict( upload_type='presentation', title='Test title', creators=[ dict(name='Doe, John', affiliation='Atlantis'), dict(name='Smith, Jane', affiliation='Atlantis') ], description='Test Description', publication_date='2013-05-08', access_right='open', license='CC0-1.0', communities=[{'identifier': 'c1'}, {'identifier': 'c3'}], ) ) # Create deposit response = client.post( deposit_url, data=json.dumps(test_data), headers=headers) data = get_json(response, code=201) # Get identifier and links current_search.flush_and_refresh(index='deposits') links = data['links'] # Upload 3 files for i in range(3): f = 'test{0}.txt'.format(i) response = client.post( links['files'], data=dict(file=(BytesIO(b'ctx'), f), name=f), headers=auth_headers, ) assert response.status_code == 201, i # Update metadata newdata = dict(metadata=data['metadata']) newdata['metadata']['title'] = 'Updated title' resdata = get_json(client.put( links['self'], data=json.dumps(newdata), headers=headers ), code=200) # Publish deposition response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) record_id = data['record_id'] assert PersistentIdentifier.query.filter_by(pid_type='depid').count() == 1 # There should be two 'recid' PIDs - Concept PID and version PID assert PersistentIdentifier.query.filter_by(pid_type='recid').count() == 2 recid_pid = PersistentIdentifier.get('recid', str(record_id)) doi_pid = PersistentIdentifier.get( pid_type='doi', pid_value='10.5072/zenodo.1') assert doi_pid.status == PIDStatus.RESERVED # This task (datacite_register) would normally be executed asynchronously datacite_register(recid_pid.pid_value, recid_pid.object_uuid) assert doi_pid.status == PIDStatus.REGISTERED # Make sure it was registered properly in datacite # It should be called twice - for concept DOI and version DOI assert datacite_mock().metadata_post.call_count == 2 # Concept DOI call datacite_mock().doi_post.assert_any_call( '10.5072/zenodo.1', 'https://zenodo.org/record/1') # Record DOI call datacite_mock().doi_post.assert_any_call( '10.5072/zenodo.2', 'https://zenodo.org/record/2') # Does record exists? current_search.flush_and_refresh(index='records') preedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) expected_doi = '10.5072/zenodo.{0}'.format(record_id) assert preedit_data['doi'] == expected_doi # - community c3 got auto-accepted (owned by deposit user) assert preedit_data['metadata']['communities'] == [{'identifier': 'c3'}] # Are files downloadable by everyone (open)? assert len(preedit_data['files']) == 3 download_url = preedit_data['files'][0]['links']['download'] assert client.get(download_url).status_code == 200 # Edit record - can now be done immediately after. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 201 # Edit - 2nd time is invalid. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 403 # FIXME 400 # Get data data = get_json(client.get(links['self'], headers=auth_headers), code=200) # Not allowed to delete assert client.delete( links['self'], headers=auth_headers).status_code == 403 # Update metadata data = dict(metadata=data['metadata']) data['metadata'].update(dict( title='New title', access_right='closed', creators=[ dict(name="Smith, Jane", affiliation="Atlantis"), dict(name="Doe, John", affiliation="Atlantis"), ], communities=[ {'identifier': 'c1'} ] )) resdata = get_json(client.put( links['self'], data=json.dumps(data), headers=headers ), code=200) assert resdata['title'] == 'New title' assert resdata['metadata']['title'] == 'New title' # Try to change DOI data['metadata']['doi'] = '10.1234/foo' data = get_json(client.put( links['self'], data=json.dumps(data), headers=headers ), code=400) # Approve community c = Community.get('c1') _, record = resolver.resolve(str(record_id)) c.accept_record(record) record.commit() db.session.commit() # Get record to confirm if both communities should be visible now assert get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200)['metadata']['communities'] == [ {'identifier': 'c1'}, {'identifier': 'c3'}, ] # Publish response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) current_search.flush_and_refresh(index='records') # - is record still accessible? postedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) # - sanity checks assert postedit_data['doi'] == expected_doi assert postedit_data['record_id'] == record_id # - files should no longer be downloadable (closed access) # - download_url worked before edit, so make sure it doesn't work now. assert 'files' not in postedit_data assert client.get(download_url).status_code == 404 # - c3 was removed, so only c1 one should be visible now assert postedit_data['metadata']['communities'] == [ {'identifier': 'c1'}, ] # Edit data = get_json(client.post(links['edit'], headers=auth_headers), code=201) # Update data = dict(metadata=data['metadata']) data['metadata'].update(dict(title='Will be discarded')) resdata = get_json(client.put( links['self'], data=json.dumps(data), headers=headers ), code=200) # Discard data = get_json( client.post(links['discard'], headers=auth_headers), code=201) # Get and assert metadata data = get_json(client.get(links['self'], headers=auth_headers), code=200) assert data['title'] == postedit_data['title']
def test_datacite_register(dc_mock, app, db, es, minimal_record): doi_tags = [ '<identifier identifierType="DOI">{doi}</identifier>', ('<relatedIdentifier relatedIdentifierType="DOI" ' 'relationType="IsPartOf">{conceptdoi}</relatedIdentifier>'), ] conceptdoi_tags = [ '<identifier identifierType="DOI">{conceptdoi}</identifier>', ] has_part_tag = ('<relatedIdentifier relatedIdentifierType="DOI" ' 'relationType="HasPart">{doi}</relatedIdentifier>') # Assert calls and content def assert_datacite_calls_and_content(record, doi_tags, conceptdoi_tags): """Datacite client calls assertion helper.""" assert dc_mock().metadata_post.call_count == 2 _, doi_args, _ = dc_mock().metadata_post.mock_calls[0] _, conceptdoi_args, _ = dc_mock().metadata_post.mock_calls[1] assert all([t.format(**record) in doi_args[0] for t in doi_tags]) assert all([ t.format(**record) in conceptdoi_args[0] for t in conceptdoi_tags ]) dc_mock().doi_post.call_count == 2 dc_mock().doi_post.assert_any_call( record['doi'], 'https://zenodo.org/record/{}'.format(record['recid'])) dc_mock().doi_post.assert_any_call( record['conceptdoi'], 'https://zenodo.org/record/{}'.format(record['conceptrecid'])) # Create conceptrecid for the records conceptrecid = PersistentIdentifier.create('recid', '100', status=PIDStatus.RESERVED) def create_versioned_record(recid_value, conceptrecid): """Utility function for creating versioned records.""" recid = PersistentIdentifier.create('recid', recid_value, status=PIDStatus.RESERVED) pv = PIDVersioning(parent=conceptrecid) pv.insert_draft_child(recid) record_metadata = deepcopy(minimal_record) record_metadata['conceptrecid'] = conceptrecid.pid_value record_metadata['recid'] = int(recid.pid_value) record = ZenodoRecord.create(record_metadata) zenodo_record_minter(record.id, record) record.commit() return recid, record # Create a reserved recid recid1, r1 = create_versioned_record('101', conceptrecid) db.session.commit() datacite_register(recid1.pid_value, str(r1.id)) conceptdoi_tags.append(has_part_tag.format(**r1)) assert_datacite_calls_and_content(r1, doi_tags, conceptdoi_tags) # Create a new version recid2, r2 = create_versioned_record('102', conceptrecid) db.session.commit() dc_mock().reset_mock() datacite_register(recid2.pid_value, str(r2.id)) conceptdoi_tags.append(has_part_tag.format(**r2)) assert_datacite_calls_and_content(r2, doi_tags, conceptdoi_tags)
def test_datacite_register(mocker, app, db, es, minimal_record): dc_mock = mocker.patch( 'invenio_pidstore.providers.datacite.DataCiteMDSClient') doi_tags = [ '<identifier identifierType="DOI">{doi}</identifier>', ('<relatedIdentifier relatedIdentifierType="DOI" ' 'relationType="IsPartOf">{conceptdoi}</relatedIdentifier>'), ] conceptdoi_tags = [ '<identifier identifierType="DOI">{conceptdoi}</identifier>', ] has_part_tag = ('<relatedIdentifier relatedIdentifierType="DOI" ' 'relationType="HasPart">{doi}</relatedIdentifier>') # Assert calls and content def assert_datacite_calls_and_content(record, doi_tags, conceptdoi_tags): """Datacite client calls assertion helper.""" assert dc_mock().metadata_post.call_count == 2 _, doi_args, _ = dc_mock().metadata_post.mock_calls[0] _, conceptdoi_args, _ = dc_mock().metadata_post.mock_calls[1] assert all([t.format(**record) in doi_args[0] for t in doi_tags]) assert all([t.format(**record) in conceptdoi_args[0] for t in conceptdoi_tags]) dc_mock().doi_post.call_count == 2 dc_mock().doi_post.assert_any_call( record['doi'], 'https://zenodo.org/record/{}'.format(record['recid'])) dc_mock().doi_post.assert_any_call( record['conceptdoi'], 'https://zenodo.org/record/{}'.format(record['conceptrecid'])) # Create conceptrecid for the records conceptrecid = PersistentIdentifier.create( 'recid', '100', status=PIDStatus.RESERVED) def create_versioned_record(recid_value, conceptrecid): """Utility function for creating versioned records.""" recid = PersistentIdentifier.create( 'recid', recid_value, status=PIDStatus.RESERVED) pv = PIDVersioning(parent=conceptrecid) pv.insert_draft_child(recid) record_metadata = deepcopy(minimal_record) record_metadata['conceptrecid'] = conceptrecid.pid_value record_metadata['recid'] = int(recid.pid_value) record = ZenodoRecord.create(record_metadata) zenodo_record_minter(record.id, record) record.commit() return recid, record # Create a reserved recid recid1, r1 = create_versioned_record('101', conceptrecid) db.session.commit() datacite_register(recid1.pid_value, str(r1.id)) conceptdoi_tags.append(has_part_tag.format(**r1)) assert_datacite_calls_and_content(r1, doi_tags, conceptdoi_tags) # Create a new version recid2, r2 = create_versioned_record('102', conceptrecid) db.session.commit() dc_mock().reset_mock() datacite_register(recid2.pid_value, str(r2.id)) conceptdoi_tags.append(has_part_tag.format(**r2)) assert_datacite_calls_and_content(r2, doi_tags, conceptdoi_tags)
def test_edit_flow( mocker, api, api_client, db, es, locations, json_auth_headers, deposit_url, get_json, auth_headers, json_headers, license_record, communities, resolver, ): """Test simple flow using REST API.""" # Stash the configuration and enable SIP writing to disk orig = api.config['SIPSTORE_ARCHIVER_WRITING_ENABLED'] api.config['SIPSTORE_ARCHIVER_WRITING_ENABLED'] = True datacite_mock = mocker.patch( 'invenio_pidstore.providers.datacite.DataCiteMDSClient') archive_task_mock = mocker.patch( 'zenodo.modules.deposit.receivers.archive_sip') headers = json_auth_headers client = api_client test_data = dict(metadata=dict( upload_type='presentation', title='Test title', creators=[ dict(name='Doe, John', affiliation='Atlantis'), dict(name='Smith, Jane', affiliation='Atlantis') ], description='Test Description', publication_date='2013-05-08', access_right='open', license='CC0-1.0', communities=[{ 'identifier': 'c1' }, { 'identifier': 'c3' }], )) # Create deposit response = client.post(deposit_url, data=json.dumps(test_data), headers=headers) data = get_json(response, code=201) # Get identifier and links current_search.flush_and_refresh(index='deposits') links = data['links'] # Upload 3 files for i in range(3): f = 'test{0}.txt'.format(i) response = client.post( links['files'], data=dict(file=(BytesIO(b'ctx'), f), name=f), headers=auth_headers, ) assert response.status_code == 201, i # Update metadata newdata = dict(metadata=data['metadata']) newdata['metadata']['title'] = 'Updated title' resdata = get_json(client.put(links['self'], data=json.dumps(newdata), headers=headers), code=200) assert not archive_task_mock.delay.called # Publish deposition response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) record_id = data['record_id'] assert PersistentIdentifier.query.filter_by(pid_type='depid').count() == 1 # There should be two 'recid' PIDs - Concept PID and version PID assert PersistentIdentifier.query.filter_by(pid_type='recid').count() == 2 recid_pid = PersistentIdentifier.get('recid', str(record_id)) doi_pid = PersistentIdentifier.get(pid_type='doi', pid_value='10.5072/zenodo.1') assert doi_pid.status == PIDStatus.RESERVED # This task (datacite_register) would normally be executed asynchronously datacite_register(recid_pid.pid_value, recid_pid.object_uuid) assert doi_pid.status == PIDStatus.REGISTERED # Make sure it was registered properly in datacite # It should be called twice - for concept DOI and version DOI assert datacite_mock().metadata_post.call_count == 2 # Concept DOI call datacite_mock().doi_post.assert_any_call('10.5072/zenodo.1', 'https://zenodo.org/record/1') # Record DOI call datacite_mock().doi_post.assert_any_call('10.5072/zenodo.2', 'https://zenodo.org/record/2') # Does record exists? current_search.flush_and_refresh(index='records') # Was SIP writing task executed? sip = RecordSIP.query.filter_by(pid_id=recid_pid.id).one().sip archive_task_mock.delay.assert_called_with(str(sip.id)) preedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) expected_doi = '10.5072/zenodo.{0}'.format(record_id) assert preedit_data['doi'] == expected_doi # - community c3 got auto-accepted (owned by deposit user) assert preedit_data['metadata']['communities'] == [{'identifier': 'c3'}] # Are files downloadable by everyone (open)? assert len(preedit_data['files']) == 3 download_url = preedit_data['files'][0]['links']['download'] assert client.get(download_url).status_code == 200 # Edit record - can now be done immediately after. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 201 # Edit - 2nd time is invalid. response = client.post(links['edit'], headers=auth_headers) assert response.status_code == 403 # FIXME 400 # Get data data = get_json(client.get(links['self'], headers=auth_headers), code=200) # Not allowed to delete assert client.delete(links['self'], headers=auth_headers).status_code == 403 # Update metadata data = dict(metadata=data['metadata']) data['metadata'].update( dict(title='New title', access_right='closed', creators=[ dict(name="Smith, Jane", affiliation="Atlantis"), dict(name="Doe, John", affiliation="Atlantis"), ], communities=[{ 'identifier': 'c1' }])) resdata = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=200) assert resdata['title'] == 'New title' assert resdata['metadata']['title'] == 'New title' # Try to change DOI data['metadata']['doi'] = '10.1234/foo' data = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=400) # Approve community c = Community.get('c1') _, record = resolver.resolve(str(record_id)) c.accept_record(record) record.commit() db.session.commit() # Get record to confirm if both communities should be visible now assert get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200)['metadata']['communities'] == [ { 'identifier': 'c1' }, { 'identifier': 'c3' }, ] # Publish response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) current_search.flush_and_refresh(index='records') # - is record still accessible? postedit_data = get_json(client.get( url_for('invenio_records_rest.recid_item', pid_value=record_id), headers=json_headers, ), code=200) # - sanity checks assert postedit_data['doi'] == expected_doi assert postedit_data['record_id'] == record_id # - files should no longer be downloadable (closed access) # - download_url worked before edit, so make sure it doesn't work now. assert 'files' not in postedit_data assert client.get(download_url).status_code == 404 # - c3 was removed, so only c1 one should be visible now assert postedit_data['metadata']['communities'] == [ { 'identifier': 'c1' }, ] # Was the second SIP sent for archiving? sip2 = RecordSIP.query.filter_by(pid_id=recid_pid.id).order_by( RecordSIP.created.desc()).first().sip archive_task_mock.delay.assert_called_with(str(sip2.id)) # Get newversion url before editing the record data = get_json(client.get(links['self'], headers=auth_headers), code=200) new_version_url = data['links']['newversion'] assert new_version_url ==\ 'http://localhost/deposit/depositions/2/actions/newversion' # Edit data = get_json(client.post(links['edit'], headers=auth_headers), code=201) # Update data = dict(metadata=data['metadata']) data['metadata'].update(dict(title='Will be discarded')) resdata = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=200) # Discard data = get_json(client.post(links['discard'], headers=auth_headers), code=201) # Get and assert metadata data = get_json(client.get(links['self'], headers=auth_headers), code=200) assert data['title'] == postedit_data['title'] # New Version data = get_json(client.post(new_version_url, headers=auth_headers), code=201) links = data['links'] # Check if UI new version link is correct assert links['latest_draft_html'] ==\ 'http://localhost/deposit/3' # Get latest version data = get_json(client.get(links['latest_draft'], headers=auth_headers), code=200) links = data['links'] # Update new version data = dict(metadata=data['metadata']) data['metadata'].update(dict(title='This is the new version')) resdata = get_json(client.put(links['self'], data=json.dumps(data), headers=headers), code=200) links = resdata['links'] # Add a file to the new deposit res = get_json(client.put( links['bucket'] + '/newfile.txt', input_stream=BytesIO(b'newfile'), headers=auth_headers, ), code=200) # Publish the new record response = client.post(links['publish'], headers=auth_headers) data = get_json(response, code=202) links = data['links'] # Get the new record data = get_json(client.get(links['record'], headers=auth_headers), code=200) # See that the title is updated accordingly assert data['metadata']['title'] == 'This is the new version' # Change the config back api.config['SIPSTORE_ARCHIVER_WRITING_ENABLED'] = orig