def _enrich_early_career_researchers(db, get_request_handler, max_workers=1): person_list = get_persons_to_enrich( db, include_early_career_researchers=True, include_roles=[] ) enrich_and_update_person_list( db, person_list, get_request_handler, max_workers=max_workers )
def test_should_not_include_person_without_a_role(self): dataset = { 'person': [PERSON_1] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich(db, include_roles=[ROLE_1]) assert {p[PERSON_ID] for p in person_list} == set()
def test_should_include_ecr_without_orcid_membership(self): dataset = { 'person': [ECR_1] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich(db, include_early_career_researchers=True) assert {p[PERSON_ID] for p in person_list} == {ECR_1[PERSON_ID]} assert {p.get('ORCID') for p in person_list} == {None}
def test_should_include_person_by_role_without_orcid_membership(self): dataset = { 'person': [PERSON_1], 'person_role': [{PERSON_ID: PERSON_ID_1, 'role': ROLE_1}] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich(db, include_roles=[ROLE_1]) assert {p[PERSON_ID] for p in person_list} == {PERSON_ID_1} LOGGER.debug('person_list: %s', person_list) assert {p.get('ORCID') for p in person_list} == {None}
def test_should_include_ecr_with_orcid_membership(self): dataset = { 'person': [ECR_1], 'person_membership': [ORCID_MEMBERSHIP_1] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich(db, include_early_career_researchers=True) assert {p[PERSON_ID] for p in person_list} == {ECR_1[PERSON_ID]} LOGGER.debug('person_list: %s', person_list) assert {p.get('ORCID') for p in person_list} == {ORCID_1}
def test_should_include_person_by_role_once_with_multiple_matching_roles(self): dataset = { 'person': [PERSON_1], 'person_role': [ {PERSON_ID: PERSON_ID_1, 'role': ROLE_1}, {PERSON_ID: PERSON_ID_1, 'role': ROLE_2} ] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich(db, include_roles=[ROLE_1, ROLE_2]) assert [p[PERSON_ID] for p in person_list] == [PERSON_ID_1]
def test_should_include_person_by_ecr_and_role(self): dataset = { 'person': [ {**PERSON_1, PERSON_ID: PERSON_ID_1}, {**ECR_1, PERSON_ID: PERSON_ID_2} ], 'person_role': [{PERSON_ID: PERSON_ID_1, 'role': ROLE_1}] } with populated_in_memory_database(dataset) as db: person_list = get_persons_to_enrich( db, include_early_career_researchers=True, include_roles=[ROLE_1] ) assert {p[PERSON_ID] for p in person_list} == {PERSON_ID_1, PERSON_ID_2}
def test_should_raise_error_if_no_filter_option_specified(self): with populated_in_memory_database(EMPTY_DATASET) as db: with pytest.raises(AssertionError): get_persons_to_enrich(db)