diff --git a/pyscicat/client.py b/pyscicat/client.py index 9c31942..120471e 100644 --- a/pyscicat/client.py +++ b/pyscicat/client.py @@ -85,7 +85,7 @@ def __init__( self._password is not None ), "SciCat login credentials (username, password) must be provided if token is not provided" self._token = get_token(self._base_url, self._username, self._password) - self._headers["Authorization"] = "Bearer {}".format(self._token) + self._headers["Authorization"] = "Bearer {}".format(self._token) def _send_to_scicat(self, cmd: str, endpoint: str, data: BaseModel = None): """sends a command to the SciCat API server using url and token, returns the response JSON diff --git a/tests/test_pyscicat/test_client.py b/tests/test_pyscicat/test_client.py index 1bd704e..364feea 100644 --- a/tests/test_pyscicat/test_client.py +++ b/tests/test_pyscicat/test_client.py @@ -9,6 +9,7 @@ encode_thumbnail, get_file_mod_time, get_file_size, + ScicatClient, ScicatCommError, ) @@ -217,5 +218,14 @@ def test_initializers(): with requests_mock.Mocker() as mock_request: add_mock_requests(mock_request) - client = from_token(local_url, "let me in!") - assert client._token == "let me in!" + client = from_token(local_url, "a_token") + assert client._token == "a_token" + assert client._headers['Authorization'] == "Bearer a_token" + + client = from_credentials(local_url, "Zaphod", "heartofgold") + assert client._token == "a_token" + assert client._headers['Authorization'] == "Bearer a_token" + + client = ScicatClient(local_url, "a_token") + assert client._token == "a_token" + assert client._headers['Authorization'] == "Bearer a_token"