1616import unittest
1717from datetime import datetime
1818
19- from hamcrest import *
2019from test .utils .env_variables import *
2120from bandwidth import ApiClient , Configuration
2221from bandwidth .api .endpoints_api import EndpointsApi
@@ -68,26 +67,26 @@ def test_create_endpoint(self) -> None:
6867 endpoint_body
6968 )
7069
71- assert_that ( response .status_code , equal_to ( 201 ))
72- assert_that (response .data , instance_of ( CreateEndpointResponse ) )
70+ assert response .status_code == 201
71+ assert isinstance (response .data , CreateEndpointResponse )
7372
74- assert_that (response .data .links , instance_of ( list ) )
75- assert_that ( len (response .data .links ), greater_than ( 0 ))
76- assert_that (response .data .links [0 ], instance_of ( Link ) )
77- assert_that ( response .data .links [0 ].href , starts_with ('http' ) )
78- assert_that ( response .data .links [0 ].rel , equal_to ( 'endpoint' ))
73+ assert isinstance (response .data .links , list )
74+ assert len (response .data .links ) > 0
75+ assert isinstance (response .data .links [0 ], Link )
76+ assert response .data .links [0 ].href . startswith ('http' )
77+ assert response .data .links [0 ].rel == 'endpoint'
7978
80- assert_that (response .data .data , instance_of ( CreateEndpointResponseData ) )
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 ))
84- assert_that (response .data .data .creation_timestamp , instance_of ( datetime ) )
85- assert_that (response .data .data .expiration_timestamp , instance_of ( datetime ) )
86- assert_that ( response .data .data .token , equal_to ( 'xxxxx.yyyyy.zzzzz' ))
87- assert_that ( response .data .data .tag , equal_to ( 'my-tag' ))
88- assert_that (response .data .data .devices , instance_of ( list ) )
79+ assert isinstance (response .data .data , CreateEndpointResponseData )
80+ assert response .data .data .endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
81+ assert response .data .data .type == EndpointTypeEnum .WEBRTC
82+ assert response .data .data .status == EndpointStatusEnum .CONNECTED
83+ assert isinstance (response .data .data .creation_timestamp , datetime )
84+ assert isinstance (response .data .data .expiration_timestamp , datetime )
85+ assert response .data .data .token == 'xxxxx.yyyyy.zzzzz'
86+ assert response .data .data .tag == 'my-tag'
87+ assert isinstance (response .data .data .devices , list )
8988
90- assert_that ( response .data .errors , equal_to ([]))
89+ assert response .data .errors == []
9190
9291 def test_delete_endpoint (self ) -> None :
9392 """Test case for delete_endpoint
@@ -99,7 +98,7 @@ def test_delete_endpoint(self) -> None:
9998 "ep-abc123"
10099 )
101100
102- assert_that ( response .status_code , equal_to ( 204 ))
101+ assert response .status_code == 204
103102
104103 def test_get_endpoint (self ) -> None :
105104 """Test case for get_endpoint
@@ -111,25 +110,25 @@ def test_get_endpoint(self) -> None:
111110 "ep-abc123"
112111 )
113112
114- assert_that ( response .status_code , equal_to ( 200 ))
115- assert_that (response .data , instance_of ( EndpointResponse ) )
113+ assert response .status_code == 200
114+ assert isinstance (response .data , EndpointResponse )
116115
117- assert_that (response .data .links , instance_of ( list ) )
118- assert_that ( len (response .data .links ), greater_than ( 0 ))
119- assert_that (response .data .links [0 ], instance_of ( Link ) )
120- assert_that ( response .data .links [0 ].href , starts_with ('http' ) )
121- assert_that ( response .data .links [0 ].rel , equal_to ( 'self' ))
116+ assert isinstance (response .data .links , list )
117+ assert len (response .data .links ) > 0
118+ assert isinstance (response .data .links [0 ], Link )
119+ assert response .data .links [0 ].href . startswith ('http' )
120+ assert response .data .links [0 ].rel == 'self'
122121
123- assert_that (response .data .data , instance_of ( Endpoint ) )
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 ))
127- assert_that (response .data .data .creation_timestamp , instance_of ( datetime ) )
128- assert_that (response .data .data .expiration_timestamp , instance_of ( datetime ) )
129- assert_that ( response .data .data .tag , equal_to ( 'my-tag' ))
130- assert_that ( response .data .data .devices , equal_to ([]))
122+ assert isinstance (response .data .data , Endpoint )
123+ assert response .data .data .endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
124+ assert response .data .data .type == EndpointTypeEnum .WEBRTC
125+ assert response .data .data .status == EndpointStatusEnum .CONNECTED
126+ assert isinstance (response .data .data .creation_timestamp , datetime )
127+ assert isinstance (response .data .data .expiration_timestamp , datetime )
128+ assert response .data .data .tag == 'my-tag'
129+ assert response .data .data .devices == []
131130
132- assert_that ( response .data .errors , equal_to ([]))
131+ assert response .data .errors == []
133132
134133 def test_list_endpoints (self ) -> None :
135134 """Test case for list_endpoints
@@ -140,33 +139,33 @@ def test_list_endpoints(self) -> None:
140139 BW_ACCOUNT_ID
141140 )
142141
143- assert_that ( response .status_code , equal_to ( 200 ))
144- assert_that (response .data , instance_of ( ListEndpointsResponse ) )
145-
146- assert_that (response .data .links , instance_of ( list ) )
147- assert_that ( len (response .data .links ), greater_than ( 0 ))
148- assert_that (response .data .links [0 ], instance_of ( Link ) )
149- assert_that ( response .data .links [0 ].href , starts_with ('http' ) )
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 ))
156-
157- assert_that (response .data .data , instance_of ( list ) )
158- assert_that ( len (response .data .data ), equal_to ( 2 ))
159- assert_that (response .data .data [0 ], instance_of ( Endpoints ) )
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' ))
164- assert_that (response .data .data [0 ].creation_timestamp , instance_of ( datetime ) )
165- 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' ))
168-
169- assert_that ( response .data .errors , equal_to ([]))
142+ assert response .status_code == 200
143+ assert isinstance (response .data , ListEndpointsResponse )
144+
145+ assert isinstance (response .data .links , list )
146+ assert len (response .data .links ) > 0
147+ assert isinstance (response .data .links [0 ], Link )
148+ assert response .data .links [0 ].href . startswith ('http' )
149+ assert response .data .links [0 ].rel == 'self'
150+
151+ assert response .data .page .page_size == 2
152+ assert response .data .page .total_elements == 10
153+ assert response .data .page .total_pages == 5
154+ assert response .data .page .page_number == 0
155+
156+ assert isinstance (response .data .data , list )
157+ assert len (response .data .data ) == 2
158+ assert isinstance (response .data .data [0 ], Endpoints )
159+ assert response .data .data [0 ].endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
160+ assert response .data .data [0 ].type == EndpointTypeEnum .WEBRTC
161+ assert response .data .data [0 ].status == EndpointStatusEnum .CONNECTED
162+ assert response .data .data [0 ].tag == 'my-tag'
163+ assert isinstance (response .data .data [0 ].creation_timestamp , datetime )
164+ assert isinstance (response .data .data [0 ].expiration_timestamp , datetime )
165+ assert response .data .data [1 ].endpoint_id == 'e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c'
166+ assert response .data .data [1 ].tag == 'my-tag'
167+
168+ assert response .data .errors == []
170169
171170
172171if __name__ == '__main__' :
0 commit comments