Skip to content

Commit

Permalink
Added a is_test parameter to Orcid class instance
Browse files Browse the repository at this point in the history
  • Loading branch information
sri0606 committed Sep 5, 2023
1 parent e65558e commit a4f03ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/pyorcid/orcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class Orcid():
'''
This is a wrapper class for ORCID API
'''
def __init__(self,orcid_id) -> None:
def __init__(self,orcid_id, is_test = False) -> None:
'''
Initialize orcid instance
orcid_id : Orcid ID of the user
'''
self._orcid_id = orcid_id
if not self.__is_access_token_valid():
if not self.__is_access_token_valid() and is_test==False:
raise ValueError("Invalid access token! Please make sure you are authenticated by ORCID as developer.")

return
Expand Down
6 changes: 3 additions & 3 deletions tests/test_orcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestOrcid(unittest.TestCase):
def test_access_token_valid(self, mock_get):
# Mock the request for access token validation
mock_get.return_value.status_code = 404
orc = Orcid(self.MY_ORCID_ID)
orc = Orcid(self.MY_ORCID_ID,is_test=True)
self.assertFalse(orc._Orcid_test_is_access_token_valid())

# similar tests for access token validation scenarios
Expand All @@ -20,7 +20,7 @@ def test_read_section_successful(self, mock_get):
# Mock the request for reading a section
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {"data": "section_data"}
orc = Orcid(self.MY_ORCID_ID)
orc = Orcid(self.MY_ORCID_ID,is_test=True)
data = orc._Orcid_test_read_section("section_name")
self.assertEqual(data, {"data": "section_data"})

Expand All @@ -31,7 +31,7 @@ def test_record_method(self, mock_get):
# Mock the request for reading a section
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {"data": "full_record_data"}
orc = Orcid(self.MY_ORCID_ID)
orc = Orcid(self.MY_ORCID_ID,is_test=True)
record = orc.test_record()
self.assertEqual(record, {"data": "full_record_data"})

Expand Down

0 comments on commit a4f03ed

Please sign in to comment.