def delete_work_for_orcid(orcid): oauth_token = TestOrcidPusherBase._oauth_token(orcid) client = OrcidClient(oauth_token, orcid) all_work = client.get_all_works_summary() for work in all_work.get("group", []): putcode = work["work-summary"][0]["put-code"] client.delete_work(putcode)
def test_get_putcodes_for_source_source_client_id_none(self): orcid = '0000-0002-4490-1930' client = OrcidClient('mytoken', orcid) response = client.get_all_works_summary() response.raise_for_result() putcodes = list( response.get_putcodes_for_source_iter('0000-0001-8607-8906')) assert len(putcodes) == 90
def __init__(self, orcid, recid, oauth_token): self.orcid = orcid self.recid = recid self.oauth_token = oauth_token try: self.inspire_record = get_db_record('lit', recid) except RecordGetterError as exc: raise exceptions.RecordNotFoundException( 'recid={} not found for pid_type=lit'.format(self.recid), from_exc=exc) self.cache = OrcidCache(orcid, recid) self.lock_name = 'orcid:{}'.format(self.orcid) self.client = OrcidClient(self.oauth_token, self.orcid) self.xml_element = None
def __init__(self, orcid, recid, oauth_token, do_fail_if_duplicated_identifier=False, record_db_version=None): self.orcid = orcid self.recid = recid self.oauth_token = oauth_token self.do_fail_if_duplicated_identifier = do_fail_if_duplicated_identifier self.record_db_version = record_db_version self.inspire_record = self._get_inspire_record() self.cache = OrcidCache(orcid, recid) self.lock_name = 'orcid:{}'.format(self.orcid) self.client = OrcidClient(self.oauth_token, self.orcid) self.converter = None
def get_putcode_for_work(orcid, token, recid): client = OrcidClient(token, orcid) response = client.get_all_works_summary() response.raise_for_result() source_client_id_path = config.get('orcid-api', 'consumer_key') putcodes = list( response.get_putcodes_for_source_iter(source_client_id_path)) if not putcodes: return None # TODO: this has to be simplified when we push recids as external # identifier (thus just the get_all_works_summary() call is required to # match recids with putcodes). for response in client.get_bulk_works_details_iter(putcodes): response.raise_for_result() for putcode, url in response.get_putcodes_and_urls_iter(): if url.endswith('/{}'.format(recid)): return putcode
def __init__( self, orcid, recid, oauth_token, pushing_duplicated_identifier=False, record_db_version=None, ): self.orcid = orcid self.recid = str(recid) self.oauth_token = oauth_token self.pushing_duplicated_identifier = pushing_duplicated_identifier self.record_db_version = record_db_version self.inspire_record = self._get_inspire_record() self.cache = OrcidCache(orcid, recid) self.lock_name = "orcid:{}".format(self.orcid) self.client = OrcidClient(self.oauth_token, self.orcid) self.converter = None self.cached_author_putcodes = {}
def __init__(self, orcid, oauth_token): self.orcid = orcid self.oauth_token = oauth_token self.client = OrcidClient(self.oauth_token, self.orcid) self.source_client_id_path = current_app.config[ 'ORCID_APP_CREDENTIALS']['consumer_key']
def orcid_client(self): return OrcidClient(self.oauth_token, self.orcid)
def delete_work(orcid, token, recid): putcode = get_putcode_for_work(orcid, token, recid) if putcode: client = OrcidClient(token, orcid) client.delete_work(putcode)
def test_invalid_token(self): client = OrcidClient('invalidtoken', self.orcid) response = client.delete_work(self.putcode) with pytest.raises(exceptions.TokenInvalidException): response.raise_for_result() assert not response.ok
def test_invalid_token(self): client = OrcidClient('invalidtoken', self.orcid) response = client.post_new_work(self.xml_element) with pytest.raises(exceptions.TokenInvalidException): response.raise_for_result() assert not response.ok
def test_invalid_token(self): client = OrcidClient('invalidtoken', self.orcid) response = client.get_all_works_summary() with pytest.raises(exceptions.TokenInvalidException): response.raise_for_result() assert not response.ok
def setup(self): self.putcodes = [ '43326850', '43255490', '43183518', '43857637', '43257979', '43938460', '43553536', '43846642', '43869107', '43466717', '43880082', '43852910', '44762573', '44762737', '44762744', '44762721', '44762617', '43257122', '43861964', '43938538', '43606530', '43855125', '44762615', '44762741', '43554289', '44762570', '44762735', '44762597', '43859780', '43941962', '43856818', '43938515', '43864453', '43875319', '43935537', '43467792', '44077351', '43554306', '44472652', '43911727', '43922432', '43916436', '43907796', '43924927', '43923874', '43938553', '43938542', '43878004', '43935695', '43881622', '43935569', '44231173', '43880802', '43938523', '43938458', '43935897', '43919253', '43918420', '43938697', '43920855', '43933388', '43942717', '43910178', '44515789', '43882441', '43935355', '43935418', '43935500', '43929711', '43935348', '43938613', '43919864', '43885354', '43935660', '43882622', '43935419', '43935519', '43942195', '43935682', '43949957', '43941870', '43938614', '43938644', '43941852', '43935478', '43937005', '44216033', '43948457', '43942230', '43938670', '43935725', '43942117', '43935577', '44227246', '43942042', '44219584', '43942229', '43942467', '43935574', '43461438', '43939244', '43942225', '43942110', '44218042', '44236863', '43942221', '43935690', '43938687', '43942306', '43326714', '43935600', '43935671', '43935595', '44229237', '43942579', '43935727', '43939389', '43935714', '44232896', '44227649', '43935744', '43938719', '43938710', '43942556', '44237648', '44226428', '43938991', '44236016', '43935746', '44236622', '43938809', '44234262', '43942562', '43939267', '43935804', '43935814', '44235446', '44238589', '43476255', '44238117', '43942245', '43935831', '44255508', '43935773', '43935525', '43349513', '43939364', '43942333', '44259358', '43334280', '43935879', '43474664', '43942483', '43868647', '43942582', '44269186', '43935857', '43939273', '44265932', '43328661', '43939436', '44575020', '44252784', '43473085', '43935955', '43329599', '43474084', '43942511', '43935852', '43325385', '43935788', '43942608', '43935829', '43942738', '43935875', '43939367', '44274797', '43328989', '43474829', '43942339', '43330602', '43939455', '43939372', '43943050', '43351389', '43328159', '43329373', '43935762', '43939467', '43943007', '43476291', '44272682', '43478322', '43343506', '43483181', '43347500', '43333264', '43858017', '43473511', '43332255', '43476010', '43350059', '44251364', '43475852', '43353967', '43849619', '43819343', '43339682', '43348858', '43333748', '44217143', '44232508', '43822751', '43939441', '43339402', '44284285', '43478099', '43356509', '43942969', '43348252', '43483990', '43936102', '43939877', '43935994', '44575015', '43939643', '44285709', '43352429', '43942965', '43364988', '44265579', '43939719', '43940213', '43368521', '43939725', '43361294', '43936167', '43293661', '43362128', '43940188', '43358238', '43936143', '44283137', '44284877', '43356836', '43939941', '44293857', '43363375', '43361159', '43365921', '43939949', '43941280', '43368183', '44291548', '43360300', '43366583', '43936275', '43370435', '43939860', '43361521', '43936314', '43942905', '43942981', '43292406', '43367691', '44317462' ] # noqa: E501 self.orcid = '0000-0002-6665-4934' # ATLAS author. try: # Pick the token from settings_local.py first. self.oauth_token = inspire_service_orcid.conf.settings.OAUTH_TOKENS.get( self.orcid) except AttributeError: self.oauth_token = 'mytoken' self.client = OrcidClient(self.oauth_token, self.orcid)
def client(self): # Pick the token from settings_local.py first. self.oauth_token = getattr(inspire_service_orcid.conf.settings, 'OAUTH_TOKENS', {}).get(self.orcid, 'mytoken') return OrcidClient(self.oauth_token, self.orcid)