示例#1
0
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
    )
示例#2
0
 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()
示例#3
0
 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}
示例#4
0
 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}
示例#5
0
 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}
示例#6
0
 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]
示例#7
0
 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}
示例#8
0
 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)