Skip to content

Commit 2561a10

Browse files
smoghe-bwclaude
andcommitted
Strengthen test assertions to check actual values instead of only types
- Model tests: Replace isinstance checks with value equality for timestamps and add missing field assertions (endpoint_response, list_endpoints_response) - Smoke tests: Add tag assertion on listed endpoint items in listEndpoints - test_list_endpoints_response: Add assertions for page.total_pages and page.page_number, plus value checks on endpoint data fields - Unit API tests: Replace instance_of/is_in with equal_to assertions using expected Prism mock values for endpoint_id, type, status, tag, token, page fields, and error arrays Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent baac7ae commit 2561a10

File tree

8 files changed

+51
-28
lines changed

8 files changed

+51
-28
lines changed

test/smoke/test_endpoints_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def listEndpoints(self):
100100
assert isinstance(endpoint.creation_timestamp, datetime)
101101
assert isinstance(endpoint.expiration_timestamp, datetime)
102102

103+
tagged_endpoint = next((ep for ep in response.data.data if ep.endpoint_id == self.endpoint_id), None)
104+
assert tagged_endpoint is not None
105+
assert tagged_endpoint.tag == "python-sdk-test-endpoint"
106+
103107
def getEndpoint(self):
104108
response: ApiResponse = self.endpoints_api_instance.get_endpoint_with_http_info(
105109
self.account_id,

test/unit/api/test_endpoints_api.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ def test_create_endpoint(self) -> None:
7575
assert_that(len(response.data.links), greater_than(0))
7676
assert_that(response.data.links[0], instance_of(Link))
7777
assert_that(response.data.links[0].href, starts_with('http'))
78-
assert_that(response.data.links[0].rel, instance_of(str))
78+
assert_that(response.data.links[0].rel, equal_to('endpoint'))
7979

8080
assert_that(response.data.data, instance_of(CreateEndpointResponseData))
81-
assert_that(response.data.data.endpoint_id, instance_of(str))
82-
assert_that(response.data.data.type, is_in(EndpointTypeEnum))
83-
assert_that(response.data.data.status, is_in(EndpointStatusEnum))
81+
assert_that(response.data.data.endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
82+
assert_that(response.data.data.type, equal_to(EndpointTypeEnum.WEBRTC))
83+
assert_that(response.data.data.status, equal_to(EndpointStatusEnum.CONNECTED))
8484
assert_that(response.data.data.creation_timestamp, instance_of(datetime))
8585
assert_that(response.data.data.expiration_timestamp, instance_of(datetime))
86-
assert_that(response.data.data.token, instance_of(str))
87-
assert_that(response.data.data.tag, instance_of(str))
86+
assert_that(response.data.data.token, equal_to('xxxxx.yyyyy.zzzzz'))
87+
assert_that(response.data.data.tag, equal_to('my-tag'))
8888
assert_that(response.data.data.devices, instance_of(list))
8989

90-
assert_that(response.data.errors, instance_of(list))
90+
assert_that(response.data.errors, equal_to([]))
9191

9292
def test_delete_endpoint(self) -> None:
9393
"""Test case for delete_endpoint
@@ -118,18 +118,18 @@ def test_get_endpoint(self) -> None:
118118
assert_that(len(response.data.links), greater_than(0))
119119
assert_that(response.data.links[0], instance_of(Link))
120120
assert_that(response.data.links[0].href, starts_with('http'))
121-
assert_that(response.data.links[0].rel, instance_of(str))
121+
assert_that(response.data.links[0].rel, equal_to('self'))
122122

123123
assert_that(response.data.data, instance_of(Endpoint))
124-
assert_that(response.data.data.endpoint_id, instance_of(str))
125-
assert_that(response.data.data.type, is_in(EndpointTypeEnum))
126-
assert_that(response.data.data.status, is_in(EndpointStatusEnum))
124+
assert_that(response.data.data.endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
125+
assert_that(response.data.data.type, equal_to(EndpointTypeEnum.WEBRTC))
126+
assert_that(response.data.data.status, equal_to(EndpointStatusEnum.CONNECTED))
127127
assert_that(response.data.data.creation_timestamp, instance_of(datetime))
128128
assert_that(response.data.data.expiration_timestamp, instance_of(datetime))
129-
assert_that(response.data.data.tag, instance_of(str))
130-
assert_that(response.data.data.devices, instance_of(list))
129+
assert_that(response.data.data.tag, equal_to('my-tag'))
130+
assert_that(response.data.data.devices, equal_to([]))
131131

132-
assert_that(response.data.errors, instance_of(list))
132+
assert_that(response.data.errors, equal_to([]))
133133

134134
def test_list_endpoints(self) -> None:
135135
"""Test case for list_endpoints
@@ -147,18 +147,26 @@ def test_list_endpoints(self) -> None:
147147
assert_that(len(response.data.links), greater_than(0))
148148
assert_that(response.data.links[0], instance_of(Link))
149149
assert_that(response.data.links[0].href, starts_with('http'))
150-
assert_that(response.data.links[0].rel, instance_of(str))
150+
assert_that(response.data.links[0].rel, equal_to('self'))
151+
152+
assert_that(response.data.page.page_size, equal_to(2))
153+
assert_that(response.data.page.total_elements, equal_to(10))
154+
assert_that(response.data.page.total_pages, equal_to(5))
155+
assert_that(response.data.page.page_number, equal_to(0))
151156

152157
assert_that(response.data.data, instance_of(list))
153-
assert_that(len(response.data.data), greater_than(0))
158+
assert_that(len(response.data.data), equal_to(2))
154159
assert_that(response.data.data[0], instance_of(Endpoints))
155-
assert_that(response.data.data[0].endpoint_id, instance_of(str))
156-
assert_that(response.data.data[0].type, is_in(EndpointTypeEnum))
157-
assert_that(response.data.data[0].status, is_in(EndpointStatusEnum))
160+
assert_that(response.data.data[0].endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
161+
assert_that(response.data.data[0].type, equal_to(EndpointTypeEnum.WEBRTC))
162+
assert_that(response.data.data[0].status, equal_to(EndpointStatusEnum.CONNECTED))
163+
assert_that(response.data.data[0].tag, equal_to('my-tag'))
158164
assert_that(response.data.data[0].creation_timestamp, instance_of(datetime))
159165
assert_that(response.data.data[0].expiration_timestamp, instance_of(datetime))
166+
assert_that(response.data.data[1].endpoint_id, equal_to('e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c'))
167+
assert_that(response.data.data[1].tag, equal_to('my-tag'))
160168

161-
assert_that(response.data.errors, instance_of(list))
169+
assert_that(response.data.errors, equal_to([]))
162170

163171

164172
if __name__ == '__main__':

test/unit/models/test_create_endpoint_response_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def testCreateEndpointResponseData(self):
7272
assert instance.endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
7373
assert instance.type == EndpointTypeEnum.WEBRTC
7474
assert instance.status == EndpointStatusEnum.CONNECTED
75-
assert isinstance(instance.creation_timestamp, datetime)
76-
assert isinstance(instance.expiration_timestamp, datetime)
75+
assert instance.creation_timestamp == datetime(2026, 1, 15, 10, 0, 0)
76+
assert instance.expiration_timestamp == datetime(2026, 1, 16, 10, 0, 0)
7777
assert instance.tag == 'my-tag'
7878
assert isinstance(instance.devices, list)
7979
assert len(instance.devices) == 1

test/unit/models/test_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def testDevice(self):
5555
assert instance.device_id == 'device-abc-123'
5656
assert instance.device_name == 'My Test Device'
5757
assert instance.status == DeviceStatusEnum.CONNECTED
58-
assert isinstance(instance.creation_timestamp, datetime)
58+
assert instance.creation_timestamp == datetime(2026, 1, 15, 10, 0, 0)
5959

6060
if __name__ == '__main__':
6161
unittest.main()

test/unit/models/test_endpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def testEndpoint(self):
7070
assert instance.endpoint_id == 'endpoint-123'
7171
assert instance.type == EndpointTypeEnum.WEBRTC
7272
assert instance.status == EndpointStatusEnum.CONNECTED
73-
assert isinstance(instance.creation_timestamp, datetime)
74-
assert isinstance(instance.expiration_timestamp, datetime)
73+
assert instance.creation_timestamp == datetime(2026, 1, 15, 10, 0, 0)
74+
assert instance.expiration_timestamp == datetime(2026, 1, 16, 10, 0, 0)
7575
assert instance.tag == 'test-endpoint'
7676
assert isinstance(instance.devices, list)
7777
assert len(instance.devices) == 1

test/unit/models/test_endpoint_response.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def testEndpointResponse(self):
6161
assert isinstance(instance.links[0], Link)
6262
assert isinstance(instance.data, Endpoint)
6363
assert instance.data.endpoint_id == 'endpoint-999'
64+
assert instance.data.type == EndpointTypeEnum.WEBRTC
65+
assert instance.data.status == EndpointStatusEnum.DISCONNECTED
66+
assert instance.data.creation_timestamp == datetime(2026, 1, 15, 10, 0, 0)
67+
assert instance.data.expiration_timestamp == datetime(2026, 1, 16, 10, 0, 0)
6468
assert isinstance(instance.errors, list)
6569

6670
if __name__ == '__main__':

test/unit/models/test_endpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def testEndpoints(self):
6060
assert instance.endpoint_id == 'endpoint-789'
6161
assert instance.type == EndpointTypeEnum.WEBRTC
6262
assert instance.status == EndpointStatusEnum.DISCONNECTED
63-
assert isinstance(instance.creation_timestamp, datetime)
64-
assert isinstance(instance.expiration_timestamp, datetime)
63+
assert instance.creation_timestamp == datetime(2026, 1, 15, 10, 0, 0)
64+
assert instance.expiration_timestamp == datetime(2026, 1, 16, 10, 0, 0)
6565
assert instance.tag == 'list-endpoint'
6666

6767
if __name__ == '__main__':

test/unit/models/test_list_endpoints_response.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,20 @@ def testListEndpointsResponse(self):
9494
assert isinstance(instance.links, list)
9595
assert len(instance.links) == 2
9696
assert isinstance(instance.page, Page)
97-
assert instance.page.total_elements == 100
9897
assert instance.page.page_size == 10
98+
assert instance.page.total_elements == 100
99+
assert instance.page.total_pages == 10
100+
assert instance.page.page_number == 1
99101
assert isinstance(instance.data, list)
100102
assert len(instance.data) == 2
101103
assert isinstance(instance.data[0], Endpoints)
102104
assert instance.data[0].endpoint_id == 'endpoint-1'
105+
assert instance.data[0].type == EndpointTypeEnum.WEBRTC
106+
assert instance.data[0].status == EndpointStatusEnum.CONNECTED
107+
assert instance.data[0].tag == 'endpoint-1-tag'
103108
assert instance.data[1].endpoint_id == 'endpoint-2'
109+
assert instance.data[1].type == EndpointTypeEnum.WEBRTC
110+
assert instance.data[1].status == EndpointStatusEnum.DISCONNECTED
104111
assert isinstance(instance.errors, list)
105112

106113
if __name__ == '__main__':

0 commit comments

Comments
 (0)