diff --git a/src/tests/test_base.py b/src/tests/test_base.py index 3cd60be..6980fa2 100644 --- a/src/tests/test_base.py +++ b/src/tests/test_base.py @@ -108,3 +108,37 @@ def test_prepare_body_form(self): # Assert self.assertTrue(content_type.startswith("multipart/form-data")) self.assertIsInstance(body, bytes) + + def test_prepare_body_file(self): + baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint) + file_content = b"test file content" + + content_type, body = baseClient.prepare_body(file_content, True, True) + + self.assertTrue(content_type.startswith("multipart/form-data")) + self.assertIsInstance(body, bytes) + self.assertIn(b"test file content", body) + + def test_do_get_bytes_raw_without_check(self): + baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint) + mock_response = b'{"key": "value"}' + url = f"{TestEndpoint}/api/test" + + with requests_mock.Mocker() as m: + m.get(url, content=mock_response) + result = baseClient.do_get_bytes_raw_without_check(url) + + self.assertEqual(result, mock_response) + + def test_do_post_bytes_raw(self): + baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint) + mock_response = b'{"status": "success"}' + url = f"{TestEndpoint}/api/test" + content_type = "application/json" + body = b'{"test": "data"}' + + with requests_mock.Mocker() as m: + m.post(url, content=mock_response) + result = baseClient.do_post_bytes_raw(url, content_type, body) + + self.assertEqual(result, mock_response) diff --git a/src/tests/test_main.py b/src/tests/test_main.py index d357e2b..db5befb 100644 --- a/src/tests/test_main.py +++ b/src/tests/test_main.py @@ -49,3 +49,32 @@ def test_casvisor_sdk_initialization(self): self.assertEqual(sdk.organizationName, organization_name) self.assertEqual(sdk.applicationName, application_name) self.assertIsInstance(sdk.baseClient, BaseClient) + + def test_casvisor_sdk_inheritance(self): + sdk = CasvisorSDK( + endpoint=TestEndpoint, + clientId=TestClientId, + clientSecret=TestClientSecret, + organizationName=TestOrganization, + applicationName=TestApplication, + ) + + self.assertTrue(hasattr(sdk, "get_records")) + self.assertTrue(hasattr(sdk, "get_record")) + self.assertTrue(hasattr(sdk, "add_record")) + self.assertTrue(hasattr(sdk, "update_record")) + self.assertTrue(hasattr(sdk, "delete_record")) + + def test_casvisor_sdk_base_client_initialization(self): + sdk = CasvisorSDK( + endpoint=TestEndpoint, + clientId=TestClientId, + clientSecret=TestClientSecret, + organizationName=TestOrganization, + applicationName=TestApplication, + ) + + self.assertIsInstance(sdk.baseClient, BaseClient) + self.assertEqual(sdk.baseClient.endpoint, TestEndpoint) + self.assertEqual(sdk.baseClient.clientId, TestClientId) + self.assertEqual(sdk.baseClient.clientSecret, TestClientSecret)