From c646e7ddbc7bffdf3c47f6d79e079f11a226191f Mon Sep 17 00:00:00 2001 From: simonwt Date: Tue, 7 Apr 2026 22:38:34 +0100 Subject: [PATCH] More APIclient testing --- src/trustcafeapiwrapper/apiclient.py | 1 - tests/apiclient.py | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/trustcafeapiwrapper/apiclient.py b/src/trustcafeapiwrapper/apiclient.py index 6e31fcb..492e255 100644 --- a/src/trustcafeapiwrapper/apiclient.py +++ b/src/trustcafeapiwrapper/apiclient.py @@ -31,7 +31,6 @@ class APIClient(BaseModel): client_id: SecretStr client_secret: SecretStr - _access_token: str = PrivateAttr(default="") _access_token_timeout: int = PrivateAttr(default=0) diff --git a/tests/apiclient.py b/tests/apiclient.py index e34b38a..fa7ec3a 100644 --- a/tests/apiclient.py +++ b/tests/apiclient.py @@ -65,11 +65,24 @@ class TestAPIClient(unittest.TestCase): debug=False, environment="invalid_env" ) - + + def test_set_environment_method(self): + self.api_client.set_environment("production") + self.assertEqual(self.api_client.environment, "production") + + def test_make_non_supported_request_type(self): + with self.assertRaises(ValueError): + self.api_client.make_request("PATCH", "content", "test") + + def test_make_request_with_bad_endpoint(self): + with self.assertRaises(ValueError): + self.api_client.make_request("GET", "invalid_endpoint", "test") + + @patch('trustcafeapiwrapper.apiclient.requests.request') def test_make_request(self, mock_request): - # This is a placeholder test. In a real test, you'd mock the HTTP request and response. - - response = self.api_client.make_request("GET", "content", "https://api.example.com/test") + # This test should be expanded + # Or the the functions should be broken up more to be more easily testable + response = self.api_client.make_request("GET", "content", "test") # mock_request.assert_called_once() \ No newline at end of file