Skip to content

Commit ff4082b

Browse files
committed
feat: Add more test cases
1 parent 5786f75 commit ff4082b

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/tests/test_base.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,37 @@ def test_prepare_body_form(self):
108108
# Assert
109109
self.assertTrue(content_type.startswith("multipart/form-data"))
110110
self.assertIsInstance(body, bytes)
111+
112+
def test_prepare_body_file(self):
113+
baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint)
114+
file_content = b"test file content"
115+
116+
content_type, body = baseClient.prepare_body(file_content, True, True)
117+
118+
self.assertTrue(content_type.startswith("multipart/form-data"))
119+
self.assertIsInstance(body, bytes)
120+
self.assertIn(b"test file content", body)
121+
122+
def test_do_get_bytes_raw_without_check(self):
123+
baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint)
124+
mock_response = b'{"key": "value"}'
125+
url = f"{TestEndpoint}/api/test"
126+
127+
with requests_mock.Mocker() as m:
128+
m.get(url, content=mock_response)
129+
result = baseClient.do_get_bytes_raw_without_check(url)
130+
131+
self.assertEqual(result, mock_response)
132+
133+
def test_do_post_bytes_raw(self):
134+
baseClient = BaseClient(TestClientId, TestClientSecret, TestEndpoint)
135+
mock_response = b'{"status": "success"}'
136+
url = f"{TestEndpoint}/api/test"
137+
content_type = "application/json"
138+
body = b'{"test": "data"}'
139+
140+
with requests_mock.Mocker() as m:
141+
m.post(url, content=mock_response)
142+
result = baseClient.do_post_bytes_raw(url, content_type, body)
143+
144+
self.assertEqual(result, mock_response)

src/tests/test_main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,32 @@ def test_casvisor_sdk_initialization(self):
4949
self.assertEqual(sdk.organizationName, organization_name)
5050
self.assertEqual(sdk.applicationName, application_name)
5151
self.assertIsInstance(sdk.baseClient, BaseClient)
52+
53+
def test_casvisor_sdk_inheritance(self):
54+
sdk = CasvisorSDK(
55+
endpoint=TestEndpoint,
56+
clientId=TestClientId,
57+
clientSecret=TestClientSecret,
58+
organizationName=TestOrganization,
59+
applicationName=TestApplication,
60+
)
61+
62+
self.assertTrue(hasattr(sdk, "get_records"))
63+
self.assertTrue(hasattr(sdk, "get_record"))
64+
self.assertTrue(hasattr(sdk, "add_record"))
65+
self.assertTrue(hasattr(sdk, "update_record"))
66+
self.assertTrue(hasattr(sdk, "delete_record"))
67+
68+
def test_casvisor_sdk_base_client_initialization(self):
69+
sdk = CasvisorSDK(
70+
endpoint=TestEndpoint,
71+
clientId=TestClientId,
72+
clientSecret=TestClientSecret,
73+
organizationName=TestOrganization,
74+
applicationName=TestApplication,
75+
)
76+
77+
self.assertIsInstance(sdk.baseClient, BaseClient)
78+
self.assertEqual(sdk.baseClient.endpoint, TestEndpoint)
79+
self.assertEqual(sdk.baseClient.clientId, TestClientId)
80+
self.assertEqual(sdk.baseClient.clientSecret, TestClientSecret)

0 commit comments

Comments
 (0)