1616import unittest
1717from datetime import datetime
1818
19+ from hamcrest import *
1920from test .utils .env_variables import *
2021from bandwidth import ApiClient , Configuration
2122from bandwidth .api .endpoints_api import EndpointsApi
@@ -68,26 +69,25 @@ def test_create_endpoint(self) -> None:
6869 endpoint_body
6970 )
7071
71- assert response .status_code == 201
72- assert isinstance (response .data , CreateEndpointResponse )
72+ assert_that ( response .status_code , equal_to ( 201 ))
73+ assert_that (response .data , instance_of ( CreateEndpointResponse ) )
7374
74- assert isinstance (response .data .links , list )
75- assert len (response .data .links ) > 0
76- assert isinstance (response .data .links [0 ], Link )
77- assert response .data .links [0 ].href .startswith ('http' )
78- assert response .data .links [0 ].rel == 'endpoint'
75+ assert_that (response .data .links , instance_of (list ))
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' ))
7979
80- assert isinstance (response .data .data , CreateEndpointResponseData )
81- assert response .data .data .endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
82- assert response .data .data .type == EndpointTypeEnum . WEBRTC
83- assert response .data .data .status == EndpointStatusEnum . CONNECTED
84- assert isinstance (response .data .data .creation_timestamp , datetime )
85- assert isinstance (response .data .data .expiration_timestamp , datetime )
86- assert response .data .data .token == 'xxxxx.yyyyy.zzzzz'
87- assert response .data .data .tag == 'my-tag'
88- assert isinstance (response .data .data .devices , list )
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 , is_in ( EndpointTypeEnum ))
83+ assert_that ( response .data .data .status , is_in ( EndpointStatusEnum ))
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 , instance_of ( str ))
87+ assert_that ( response .data .data .tag , instance_of ( str ))
88+ assert_that (response .data .data .devices , instance_of ( list ) )
8989
90- assert response .data .errors == []
90+ assert_that ( response .data .errors , instance_of ( list ))
9191
9292 def test_delete_endpoint (self ) -> None :
9393 """Test case for delete_endpoint
@@ -99,7 +99,7 @@ def test_delete_endpoint(self) -> None:
9999 "ep-abc123"
100100 )
101101
102- assert response .status_code == 204
102+ assert_that ( response .status_code , equal_to ( 204 ))
103103
104104 def test_get_endpoint (self ) -> None :
105105 """Test case for get_endpoint
@@ -111,25 +111,24 @@ def test_get_endpoint(self) -> None:
111111 "ep-abc123"
112112 )
113113
114- assert response .status_code == 200
115- assert isinstance (response .data , EndpointResponse )
114+ assert_that ( response .status_code , equal_to ( 200 ))
115+ assert_that (response .data , instance_of ( EndpointResponse ) )
116116
117- assert isinstance (response .data .links , list )
118- assert len (response .data .links ) > 0
119- assert isinstance (response .data .links [0 ], Link )
120- assert response .data .links [0 ].href .startswith ('http' )
121- assert response .data .links [0 ].rel == 'self'
117+ assert_that (response .data .links , instance_of (list ))
118+ assert_that (response .data .links [0 ], instance_of (Link ))
119+ assert_that (response .data .links [0 ].href , starts_with ('http' ))
120+ assert_that (response .data .links [0 ].rel , equal_to ('self' ))
122121
123- assert isinstance (response .data .data , Endpoint )
124- assert response .data .data .endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
125- assert response .data .data .type == EndpointTypeEnum . WEBRTC
126- assert response .data .data .status == EndpointStatusEnum . CONNECTED
127- assert isinstance (response .data .data .creation_timestamp , datetime )
128- assert isinstance (response .data .data .expiration_timestamp , datetime )
129- assert response .data .data .tag == 'my-tag'
130- assert response .data .data .devices == []
122+ assert_that (response .data .data , instance_of ( Endpoint ) )
123+ assert_that ( response .data .data .endpoint_id , equal_to ( 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' ))
124+ assert_that ( response .data .data .type , is_in ( EndpointTypeEnum ))
125+ assert_that ( response .data .data .status , is_in ( EndpointStatusEnum ))
126+ assert_that (response .data .data .creation_timestamp , instance_of ( datetime ) )
127+ assert_that (response .data .data .expiration_timestamp , instance_of ( datetime ) )
128+ assert_that ( response .data .data .tag , instance_of ( str ))
129+ assert_that ( response .data .data .devices , instance_of ( list ))
131130
132- assert response .data .errors == []
131+ assert_that ( response .data .errors , instance_of ( list ))
133132
134133 def test_list_endpoints (self ) -> None :
135134 """Test case for list_endpoints
@@ -140,33 +139,32 @@ def test_list_endpoints(self) -> None:
140139 BW_ACCOUNT_ID
141140 )
142141
143- assert response .status_code == 200
144- assert isinstance (response .data , ListEndpointsResponse )
145-
146- assert isinstance (response .data .links , list )
147- assert len (response .data .links ) > 0
148- assert isinstance (response .data .links [0 ], Link )
149- assert response .data .links [0 ].href .startswith ('http' )
150- assert response .data .links [0 ].rel == 'self'
151-
152- assert response .data .page .page_size == 2
153- assert response .data .page .total_elements == 10
154- assert response .data .page .total_pages == 5
155- assert response .data .page .page_number == 0
156-
157- assert isinstance (response .data .data , list )
158- assert len (response .data .data ) == 2
159- assert isinstance (response .data .data [0 ], Endpoints )
160- assert response .data .data [0 ].endpoint_id == 'e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
161- assert response .data .data [0 ].type == EndpointTypeEnum .WEBRTC
162- assert response .data .data [0 ].status == EndpointStatusEnum .CONNECTED
163- assert response .data .data [0 ].tag == 'my-tag'
164- assert isinstance (response .data .data [0 ].creation_timestamp , datetime )
165- assert isinstance (response .data .data [0 ].expiration_timestamp , datetime )
166- assert response .data .data [1 ].endpoint_id == 'e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c'
167- assert response .data .data [1 ].tag == 'my-tag'
168-
169- assert response .data .errors == []
142+ assert_that (response .status_code , equal_to (200 ))
143+ assert_that (response .data , instance_of (ListEndpointsResponse ))
144+
145+ assert_that (response .data .links , instance_of (list ))
146+ assert_that (response .data .links [0 ], instance_of (Link ))
147+ assert_that (response .data .links [0 ].href , starts_with ('http' ))
148+ assert_that (response .data .links [0 ].rel , equal_to ('self' ))
149+
150+ assert_that (response .data .page , instance_of (Page ))
151+ assert_that (response .data .page .page_size , equal_to (2 ))
152+ assert_that (response .data .page .total_elements , equal_to (10 ))
153+ assert_that (response .data .page .total_pages , equal_to (5 ))
154+ assert_that (response .data .page .page_number , equal_to (0 ))
155+
156+ assert_that (response .data .data , instance_of (list ))
157+ assert_that (response .data .data [0 ], instance_of (Endpoints ))
158+ assert_that (response .data .data [0 ].endpoint_id , equal_to ('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' ))
159+ assert_that (response .data .data [0 ].type , is_in (EndpointTypeEnum ))
160+ assert_that (response .data .data [0 ].status , is_in (EndpointStatusEnum ))
161+ assert_that (response .data .data [0 ].tag , instance_of (str ))
162+ assert_that (response .data .data [0 ].creation_timestamp , instance_of (datetime ))
163+ assert_that (response .data .data [0 ].expiration_timestamp , instance_of (datetime ))
164+ assert_that (response .data .data [1 ].endpoint_id , equal_to ('e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c' ))
165+ assert_that (response .data .data [1 ].tag , instance_of (str ))
166+
167+ assert_that (response .data .errors , instance_of (list ))
170168
171169
172170if __name__ == '__main__' :
0 commit comments