def test_append_updated_record_to_queue_not_hep_record(small_app): """Test if the receiver will skip an updated publication, not HEP.""" sample_author_record = _IdDict({ '$schema': 'http://localhost:5000/schemas/records/authors.json', 'collections': [{ 'primary': 'HEPNAMES' }], 'control_number': '314159265', 'name': { 'value': 'Glashow, S.L.' }, 'positions': [{ 'institution': { 'name': 'Copenhagen U.' } }], 'self': { '$ref': 'http://localhost:5000/api/authors/314159265' } }) append_updated_record_to_queue(None, sample_author_record, sample_author_record, "records-authors", "authors") assert str(sample_author_record.id) != \ DisambiguationRecord.query.order_by(desc("id")).first().record_id
def test_append_updated_record_to_queue_same_data(small_app): """Check if for the same record, the receiver will skip the publication.""" pid = PersistentIdentifier.get('lit', 11883) publication_id = str(pid.object_uuid) record = InspireRecord.get_record(publication_id) append_updated_record_to_queue(None, record, record, 'records-hep', 'hep') assert str(record.id) != \ DisambiguationRecord.query.order_by(desc('id')).first().record_id
def test_append_updated_record_to_queue_same_data(small_app): """Check if for the same record, the receiver will skip the publication.""" pid = PersistentIdentifier.get("literature", 11883) publication_id = str(pid.object_uuid) record = Record.get_record(publication_id) append_updated_record_to_queue(None, record, record, "records-hep", "hep") assert str(record.id) != \ DisambiguationRecord.query.order_by(desc("id")).first().record_id
def test_append_updated_record_to_queue(small_app): """Test the receiver responsible for queuing updated HEP records.""" pid = PersistentIdentifier.get('lit', 4328) publication_id = str(pid.object_uuid) record = InspireRecord.get_record(publication_id) record_to_update = deepcopy(record) record_to_update['authors'][0]['full_name'] = 'John Smith' append_updated_record_to_queue(None, record_to_update, record_to_update, 'records-hep', 'hep') assert str(record_to_update.id) == \ DisambiguationRecord.query.order_by(desc('id')).first().record_id
def test_append_updated_record_to_queue(small_app): """Test the receiver responsible for queuing updated HEP records.""" pid = PersistentIdentifier.get("literature", 4328) publication_id = str(pid.object_uuid) record = Record.get_record(publication_id) record_to_update = deepcopy(record) record_to_update['authors'][0]['full_name'] = "John Smith" append_updated_record_to_queue(None, record_to_update, record_to_update, "records-hep", "hep") assert str(record_to_update.id) == \ DisambiguationRecord.query.order_by(desc("id")).first().record_id
def test_append_updated_record_to_queue(small_app): """Test the receiver responsible for queuing updated HEP records.""" pid = PersistentIdentifier.get('lit', 4328) publication_id = str(pid.object_uuid) record = InspireRecord.get_record(publication_id) record_to_update = deepcopy(record) record_to_update['authors'][0]['full_name'] = 'John Smith' append_updated_record_to_queue(None, record_to_update, record_to_update, 'records-hep', 'hep') assert str(record_to_update.id) == \ DisambiguationRecord.query.order_by(desc('id')).first().record_id
def test_append_updated_record_to_queue(small_app): """Test the receiver responsible for queuing updated HEP records.""" pid = PersistentIdentifier.get("literature", 4328) publication_id = str(pid.object_uuid) record = Record.get_record(publication_id) record_to_update = deepcopy(record) record_to_update['authors'][0]['full_name'] = "John Smith" append_updated_record_to_queue(None, record_to_update, record_to_update, "records-hep", "hep") assert str(record_to_update.id) == \ DisambiguationRecord.query.order_by(desc("id")).first().record_id
def test_append_updated_record_to_queue_not_hep_record(small_app): """Test if the receiver will skip an updated publication, not HEP.""" sample_author_record = _IdDict({ '$schema': 'http://localhost:5000/schemas/records/authors.json', '_collections': ['Authors'], 'control_number': 314159265, 'name': {'value': 'Glashow, S.L.'}, 'positions': [{'institution': {'name': 'Copenhagen U.'}}], 'self': {'$ref': 'http://localhost:5000/api/authors/314159265'}}) append_updated_record_to_queue(None, sample_author_record, sample_author_record, 'records-authors', 'authors') assert str(sample_author_record.id) != \ DisambiguationRecord.query.order_by(desc('id')).first().record_id
def test_append_updated_record_to_queue_new_record(small_app): """Test if the receiver will return None, since the record will not be found in the Elasticsearch instance. This record will be caught by 'append_new_record_to_queue' signal. """ sample_hep_record = _IdDict({ '$schema': 'http://localhost:5000/schemas/records/hep.json', '_collections': ['Literature'], 'authors': [{ 'affiliations': [{'value': 'Copenhagen U.'}], 'curated_relation': False, 'full_name': 'Glashow, S.L.', 'signature_block': 'GLASs', 'uuid': '5ece3c81-0a50-481d-8bee-5f78576e9504' }], 'control_number': 4328, 'self': {'$ref': 'http://localhost:5000/api/literature/4328'}, 'titles': [{'title': 'Partial Symmetries of Weak Interactions'}] }) result = append_updated_record_to_queue(None, sample_hep_record, sample_hep_record, 'records-hep', 'hep') assert result is None assert str(sample_hep_record.id) != \ DisambiguationRecord.query.order_by(desc('id')).first().record_id
def test_append_updated_record_to_queue_new_record(small_app): """Test if the receiver will return None, since the record will not be found in the Elasticsearch instance. This record will be caught by 'append_new_record_to_queue' signal. """ sample_hep_record = _IdDict({ '$schema': 'http://localhost:5000/schemas/records/hep.json', 'authors': [{ 'affiliations': [{ 'value': 'Copenhagen U.' }], 'curated_relation': False, 'full_name': 'Glashow, S.L.', 'signature_block': 'GLASs', 'uuid': '5ece3c81-0a50-481d-8bee-5f78576e9504' }], 'collections': [{ 'primary': 'CORE' }, { 'primary': 'HEP' }], 'control_number': '4328', 'self': { '$ref': 'http://localhost:5000/api/literature/4328' }, 'titles': [{ 'title': 'Partial Symmetries of Weak Interactions' }] }) result = append_updated_record_to_queue(None, sample_hep_record, sample_hep_record, "records-hep", "hep") assert result is None assert str(sample_hep_record.id) != \ DisambiguationRecord.query.order_by(desc("id")).first().record_id