44import unittest
55from datetime import datetime
66
7- from hamcrest import assert_that , has_properties , instance_of , equal_to , greater_than
8-
97from bandwidth import ApiClient , ApiResponse , Configuration
108from bandwidth .api .endpoints_api import EndpointsApi
119from bandwidth .models .create_web_rtc_connection_request import CreateWebRtcConnectionRequest
@@ -57,22 +55,21 @@ def createEndpoint(self):
5755 create_request
5856 )
5957
60- assert_that (response .status_code , equal_to (201 ))
61- assert_that (response .data , instance_of (CreateEndpointResponse ))
62- assert_that (response .data .links , instance_of (list ))
63- assert_that (len (response .data .links ), equal_to (0 ))
64- assert_that (response .data .errors , instance_of (list ))
65- assert_that (response .data .data , instance_of (CreateEndpointResponseData ))
66- assert_that (response .data .data , has_properties (
67- 'endpoint_id' , instance_of (str ),
68- 'type' , EndpointTypeEnum .WEBRTC ,
69- 'status' , instance_of (EndpointStatusEnum ),
70- 'token' , instance_of (str ),
71- 'creation_timestamp' , instance_of (datetime ),
72- 'expiration_timestamp' , instance_of (datetime ),
73- 'tag' , equal_to ("python-sdk-test-endpoint" ),
74- 'devices' , instance_of (list )
75- ))
58+ assert response .status_code == 201
59+ assert isinstance (response .data , CreateEndpointResponse )
60+ assert isinstance (response .data .links , list )
61+ assert len (response .data .links ) == 0
62+ assert isinstance (response .data .errors , list )
63+ assert len (response .data .errors ) == 0
64+ assert isinstance (response .data .data , CreateEndpointResponseData )
65+ assert isinstance (response .data .data .endpoint_id , str )
66+ assert response .data .data .type == EndpointTypeEnum .WEBRTC
67+ assert isinstance (response .data .data .status , EndpointStatusEnum )
68+ assert isinstance (response .data .data .token , str )
69+ assert isinstance (response .data .data .creation_timestamp , datetime )
70+ assert isinstance (response .data .data .expiration_timestamp , datetime )
71+ assert response .data .data .tag == "python-sdk-test-endpoint"
72+ assert isinstance (response .data .data .devices , list )
7673
7774 self .__class__ .endpoint_id = response .data .data .endpoint_id
7875
@@ -83,68 +80,54 @@ def listEndpoints(self):
8380 limit = 10
8481 )
8582
86- assert_that (response .status_code , equal_to (200 ))
87- assert_that (response .data , instance_of (ListEndpointsResponse ))
88- assert_that (response .data .links , instance_of (list ))
89- assert_that (len (response .data .links ), equal_to (0 ))
90- assert_that (response .data .errors , instance_of (list ))
91- assert_that (response .data .data , instance_of (list ))
92- assert_that (len (response .data .data ), greater_than (0 ))
83+ assert response .status_code == 200
84+ assert isinstance (response .data , ListEndpointsResponse )
85+ assert isinstance (response .data .links , list )
86+ assert len (response .data .links ) == 0
87+ assert isinstance (response .data .errors , list )
88+ assert len (response .data .errors ) == 0
89+ assert isinstance (response .data .data , list )
90+ assert len (response .data .data ) > 0
9391
9492 listed_ids = [ep .endpoint_id for ep in response .data .data ]
95- assert_that ( self .endpoint_id in listed_ids , equal_to ( True ))
93+ assert self .endpoint_id in listed_ids
9694
9795 endpoint = response .data .data [0 ]
98- assert_that (endpoint , instance_of (Endpoints ))
99- assert_that (endpoint , has_properties (
100- 'endpoint_id' , instance_of (str ),
101- 'type' , instance_of (EndpointTypeEnum ),
102- 'status' , instance_of (EndpointStatusEnum ),
103- 'creation_timestamp' , instance_of (datetime ),
104- 'expiration_timestamp' , instance_of (datetime )
105- ))
96+ assert isinstance (endpoint , Endpoints )
97+ assert isinstance (endpoint .endpoint_id , str )
98+ assert isinstance (endpoint .type , EndpointTypeEnum )
99+ assert isinstance (endpoint .status , EndpointStatusEnum )
100+ assert isinstance (endpoint .creation_timestamp , datetime )
101+ assert isinstance (endpoint .expiration_timestamp , datetime )
106102
107103 def getEndpoint (self ):
108104 response : ApiResponse = self .endpoints_api_instance .get_endpoint_with_http_info (
109105 self .account_id ,
110106 self .endpoint_id
111107 )
112108
113- assert_that (response .status_code , equal_to (200 ))
114- assert_that (response .data , instance_of (EndpointResponse ))
115- assert_that (response .data .links , instance_of (list ))
116- assert_that (len (response .data .links ), equal_to (0 ))
117- assert_that (response .data .errors , instance_of (list ))
118- assert_that (response .data .data , instance_of (Endpoint ))
119- assert_that (response .data .data , has_properties (
120- 'endpoint_id' , equal_to (self .endpoint_id ),
121- 'type' , EndpointTypeEnum .WEBRTC ,
122- 'status' , instance_of (EndpointStatusEnum ),
123- 'creation_timestamp' , instance_of (datetime ),
124- 'expiration_timestamp' , instance_of (datetime ),
125- 'tag' , equal_to ("python-sdk-test-endpoint" ),
126- 'devices' , instance_of (list )
127- ))
128-
129- # Note: This endpoint is currently not working in the API, so this test is commented out for now. Once the API issue is resolved, this test should be uncommented and verified.
130- # def updateEndpointBxml(self):
131- # bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><StartStream name="test_stream"/></Bxml>'
132- # response: ApiResponse = self.endpoints_api_instance.update_endpoint_bxml_with_http_info(
133- # self.account_id,
134- # self.endpoint_id,
135- # bxml
136- # )
137- #
138- # assert_that(response.status_code, equal_to(204))
139- # ...
109+ assert response .status_code == 200
110+ assert isinstance (response .data , EndpointResponse )
111+ assert isinstance (response .data .links , list )
112+ assert len (response .data .links ) == 0
113+ assert isinstance (response .data .errors , list )
114+ assert len (response .data .errors ) == 0
115+ assert isinstance (response .data .data , Endpoint )
116+ assert response .data .data .endpoint_id == self .endpoint_id
117+ assert response .data .data .type == EndpointTypeEnum .WEBRTC
118+ assert isinstance (response .data .data .status , EndpointStatusEnum )
119+ assert isinstance (response .data .data .creation_timestamp , datetime )
120+ assert isinstance (response .data .data .expiration_timestamp , datetime )
121+ assert response .data .data .tag == "python-sdk-test-endpoint"
122+ assert isinstance (response .data .data .devices , list )
140123
141124 def deleteEndpoint (self ):
142125 response : ApiResponse = self .endpoints_api_instance .delete_endpoint_with_http_info (
143126 self .account_id ,
144127 self .endpoint_id
145128 )
146129
147- assert_that ( response .status_code , equal_to ( 204 ))
130+ assert response .status_code == 204
148131
149132 def _steps (self ):
150133 call_order = ['createEndpoint' , 'listEndpoints' , 'getEndpoint' , 'deleteEndpoint' ]
@@ -156,9 +139,7 @@ def test_steps(self):
156139 step ()
157140
158141 def assertApiException (self , context , expected_status_code : int ):
159- assert_that (context .exception , has_properties (
160- 'status' , expected_status_code ,
161- ))
142+ assert context .exception .status == expected_status_code
162143
163144 def test_create_endpoint_unauthorized (self ):
164145 create_request = CreateWebRtcConnectionRequest (
0 commit comments