44import unittest
55from datetime import datetime
66
7+ from hamcrest import assert_that , not_none , instance_of , equal_to , greater_than
8+
79from bandwidth import ApiClient , ApiResponse , Configuration
810from bandwidth .api .endpoints_api import EndpointsApi
911from bandwidth .models .create_web_rtc_connection_request import CreateWebRtcConnectionRequest
@@ -55,21 +57,19 @@ def createEndpoint(self):
5557 create_request
5658 )
5759
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 )
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 (response .data .errors , instance_of (list ))
64+ assert_that (response .data .data , instance_of (CreateEndpointResponseData ))
65+ assert_that (response .data .data .endpoint_id , instance_of (str ))
66+ assert_that (response .data .data .type , equal_to (EndpointTypeEnum .WEBRTC ))
67+ assert_that (response .data .data .status , instance_of (EndpointStatusEnum ))
68+ assert_that (response .data .data .token , instance_of (str ))
69+ assert_that (response .data .data .creation_timestamp , instance_of (datetime ))
70+ assert_that (response .data .data .expiration_timestamp , instance_of (datetime ))
71+ assert_that (response .data .data .tag , equal_to ("python-sdk-test-endpoint" ))
72+ assert_that (response .data .data .devices , instance_of (list ))
7373
7474 self .__class__ .endpoint_id = response .data .data .endpoint_id
7575
@@ -80,55 +80,51 @@ def listEndpoints(self):
8080 limit = 10
8181 )
8282
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
83+ assert_that (response .status_code , equal_to (200 ))
84+ assert_that (response .data , instance_of (ListEndpointsResponse ))
85+ assert_that (response .data .links , instance_of (list ))
86+ assert_that (response .data .errors , instance_of (list ))
87+ assert_that (response .data .data , instance_of (list ))
88+ assert_that (len (response .data .data ), greater_than (0 ))
9189
9290 endpoint = response .data .data [0 ]
93- assert isinstance (endpoint , Endpoints )
94- assert isinstance (endpoint .endpoint_id , str )
95- assert isinstance (endpoint .type , EndpointTypeEnum )
96- assert isinstance (endpoint .status , EndpointStatusEnum )
97- assert isinstance (endpoint .creation_timestamp , datetime )
98- assert isinstance (endpoint .expiration_timestamp , datetime )
91+ assert_that (endpoint , instance_of ( Endpoints ) )
92+ assert_that (endpoint .endpoint_id , instance_of ( str ) )
93+ assert_that (endpoint .type , instance_of ( EndpointTypeEnum ) )
94+ assert_that (endpoint .status , instance_of ( EndpointStatusEnum ) )
95+ assert_that (endpoint .creation_timestamp , instance_of ( datetime ) )
96+ assert_that (endpoint .expiration_timestamp , instance_of ( datetime ) )
9997
10098 tagged_endpoint = next ((ep for ep in response .data .data if ep .endpoint_id == self .endpoint_id ), None )
101- assert tagged_endpoint is not None
102- assert tagged_endpoint .tag == "python-sdk-test-endpoint"
99+ assert_that ( tagged_endpoint , not_none ())
100+ assert_that ( tagged_endpoint .tag , equal_to ( "python-sdk-test-endpoint" ))
103101
104102 def getEndpoint (self ):
105103 response : ApiResponse = self .endpoints_api_instance .get_endpoint_with_http_info (
106104 self .account_id ,
107105 self .endpoint_id
108106 )
109107
110- assert response .status_code == 200
111- assert isinstance (response .data , EndpointResponse )
112- assert isinstance (response .data .links , list )
113- assert len (response .data .links ) == 0
114- assert isinstance (response .data .errors , list )
115- assert len (response .data .errors ) == 0
116- assert isinstance (response .data .data , Endpoint )
117- assert response .data .data .endpoint_id == self .endpoint_id
118- assert response .data .data .type == EndpointTypeEnum .WEBRTC
119- assert isinstance (response .data .data .status , EndpointStatusEnum )
120- assert isinstance (response .data .data .creation_timestamp , datetime )
121- assert isinstance (response .data .data .expiration_timestamp , datetime )
122- assert response .data .data .tag == "python-sdk-test-endpoint"
123- assert isinstance (response .data .data .devices , list )
108+ assert_that (response .status_code , equal_to (200 ))
109+ assert_that (response .data , instance_of (EndpointResponse ))
110+ assert_that (response .data .links , instance_of (list ))
111+ assert_that (response .data .errors , instance_of (list ))
112+ assert_that (response .data .data , instance_of (Endpoint ))
113+ assert_that (response .data .data .endpoint_id , equal_to (self .endpoint_id ))
114+ assert_that (response .data .data .type , equal_to (EndpointTypeEnum .WEBRTC ))
115+ assert_that (response .data .data .status , instance_of (EndpointStatusEnum ))
116+ assert_that (response .data .data .creation_timestamp , instance_of (datetime ))
117+ assert_that (response .data .data .expiration_timestamp , instance_of (datetime ))
118+ assert_that (response .data .data .tag , equal_to ("python-sdk-test-endpoint" ))
119+ assert_that (response .data .data .devices , instance_of (list ))
124120
125121 def deleteEndpoint (self ):
126122 response : ApiResponse = self .endpoints_api_instance .delete_endpoint_with_http_info (
127123 self .account_id ,
128124 self .endpoint_id
129125 )
130126
131- assert response .status_code == 204
127+ assert_that ( response .status_code , equal_to ( 204 ))
132128
133129 def _steps (self ):
134130 call_order = ['createEndpoint' , 'listEndpoints' , 'getEndpoint' , 'deleteEndpoint' ]
@@ -140,7 +136,8 @@ def test_steps(self):
140136 step ()
141137
142138 def assertApiException (self , context , expected_status_code : int ):
143- assert context .exception .status == expected_status_code
139+ assert_that (context .exception .status , equal_to (expected_status_code ))
140+ assert_that (context .exception .body , not_none ())
144141
145142 def test_create_endpoint_unauthorized (self ):
146143 create_request = CreateWebRtcConnectionRequest (
0 commit comments