def test_putcode_not_found(self):
     self.orcid = "0000-0002-0942-3697"
     with override_config(ORCID_APP_CREDENTIALS={
             "consumer_key": self.source_client_id_path
     }):
         putcode_getter = OrcidPutcodeGetter(self.orcid, self.oauth_token)
         with pytest.raises(exceptions.InputDataInvalidException):
             list(putcode_getter.get_all_inspire_putcodes_and_recids_iter())
 def test_get_all_inspire_putcodes_with_recids(self):
     self.orcid = "0000-0002-5073-0816"
     with override_config(ORCID_APP_CREDENTIALS={
             "consumer_key": self.source_client_id_path
     }):
         putcode_getter = OrcidPutcodeGetter(self.orcid, self.oauth_token)
         putcodes_recids = list(
             putcode_getter.get_all_inspire_putcodes_and_recids_iter())
     assert putcodes_recids == [("51341099", "20"), ("51341192", "20")]
 def test_token_invalid(self):
     token = "invalid"
     putcode_getter = OrcidPutcodeGetter(self.orcid, token)
     with pytest.raises(
             exceptions.TokenInvalidDeletedException), mock.patch(
                 "inspirehep.orcid.push_access_tokens.delete_access_token"
             ) as mock_delete_access_token:
         list(putcode_getter.get_all_inspire_putcodes_and_recids_iter())
     mock_delete_access_token.assert_called_once_with(token, self.orcid)
 def test_get_all_inspire_putcodes_happy_flow(self):
     with override_config(ORCID_APP_CREDENTIALS={
             "consumer_key": self.source_client_id_path
     }):
         putcode_getter = OrcidPutcodeGetter(self.orcid, self.oauth_token)
         putcodes_recids = list(
             putcode_getter.get_all_inspire_putcodes_and_recids_iter())
     assert len(putcodes_recids) == 297
     for _, recid in putcodes_recids:
         assert int(recid)
 def test_get_putcodes_and_recids_by_identifiers_iter(self, ):
     self.orcid = "0000-0002-0942-3697"
     id_doi1 = ExternalIdentifier("doi", "10.1000/test.orcid.push")
     id_doi2 = ExternalIdentifier("doi",
                                  "10.1000/orcid-test-andrea-rossoni")
     with override_config(ORCID_APP_CREDENTIALS={
             "consumer_key": self.source_client_id_path
     }):
         putcode_getter = OrcidPutcodeGetter(self.orcid, self.oauth_token)
         putcodes_recids = list(
             putcode_getter.get_putcodes_and_recids_by_identifiers_iter(
                 [id_doi1, id_doi2]))
     assert putcodes_recids == [(51548299, "999"), (51344802, "1680808")]