Skip to content

Commit

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

#For testing purposes (pytesting on github workflow)
try:
self.__test_is_access_token_valid()
except:
if not self.__is_access_token_valid():
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,is_test=True)
orc = Orcid(self.MY_ORCID_ID)
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,is_test=True)
orc = Orcid(self.MY_ORCID_ID)
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,is_test=True)
orc = Orcid(self.MY_ORCID_ID)
record = orc._Orcid__test_record()
self.assertEqual(record, {"data": "full_record_data"})

Expand Down

0 comments on commit 600e5f8

Please sign in to comment.