def test_get_uuid_from_pid_value_returns_original_record_when_requested( inspire_app): redirected_record = create_record("lit") record = create_record( "lit", data={"deleted_records": [dict(redirected_record["self"])]}) original_record = LiteratureRecord.get_uuid_from_pid_value( redirected_record.control_number, original_record=True) new_record = LiteratureRecord.get_uuid_from_pid_value( redirected_record.control_number) assert original_record != new_record assert original_record == redirected_record.id assert new_record == record.id
def test_migrate_from_mirror_doesnt_index_deleted_records(inspire_app): record_fixture_path = pkg_resources.resource_filename( __name__, os.path.join("fixtures", "dummy.xml")) record_fixture_path_deleted = pkg_resources.resource_filename( __name__, os.path.join("fixtures", "deleted_record.xml")) migrate_from_file(record_fixture_path) migrate_from_file(record_fixture_path_deleted) current_search.flush_and_refresh("records-hep") expected_record_lit_es_len = 1 record_lit_uuid = LiteratureRecord.get_uuid_from_pid_value(12345) with pytest.raises(PIDDoesNotExistError): LiteratureRecord.get_uuid_from_pid_value(1234) record_lit_es = LiteratureSearch().get_record( str(record_lit_uuid)).execute().hits record_lit_es_len = len(record_lit_es) assert expected_record_lit_es_len == record_lit_es_len
def test_migrate_from_mirror_removes_record_from_es(inspire_app, datadir): data = orjson.loads((datadir / "dummy_record.json").read_text()) create_record("lit", data=data) expected_record_lit_es_len = 1 record_lit_uuid = LiteratureRecord.get_uuid_from_pid_value(12345) record_lit_es = LiteratureSearch().get_record(str(record_lit_uuid)).execute().hits record_lit_es_len = len(record_lit_es) assert expected_record_lit_es_len == record_lit_es_len record_deleted_fixture_path = pkg_resources.resource_filename( __name__, os.path.join("fixtures", "dummy_deleted.xml") ) migrate_from_file(record_deleted_fixture_path) current_search.flush_and_refresh("records-hep") expected_record_lit_es_len = 0 record_lit_uuid = LiteratureRecord.get_uuid_from_pid_value(12345) record_lit_es = LiteratureSearch().get_record(str(record_lit_uuid)).execute().hits record_lit_es_len = len(record_lit_es) assert expected_record_lit_es_len == record_lit_es_len