77 PyProxyAlreadyExists ,
88 PyProxyNotFound ,
99 PyProxyInvalidInput ,
10- PyProxyServerError
10+ PyProxyServerError ,
1111)
1212
13+
1314class TestPyProxyClient (unittest .TestCase ):
1415
1516 def setUp (self ):
16- self .client = PyProxyClient (base_url = "http://localhost:5000" , username = "admin" , password = "password" )
17+ self .client = PyProxyClient (
18+ base_url = "http://localhost:5000" ,
19+ username = "admin" ,
20+ password = "password" ,
21+ )
1722
1823 def test_missing_base_url (self ):
1924 with self .assertRaises (PyProxyConfigurationError ):
20- PyProxyClient (base_url = None , username = "admin" , password = "password" )
25+ PyProxyClient (
26+ base_url = None ,
27+ username = "admin" ,
28+ password = "password" ,
29+ )
2130
2231 def test_missing_username (self ):
2332 with self .assertRaises (PyProxyConfigurationError ):
24- PyProxyClient (base_url = "http://localhost:5000" , username = None , password = "password" )
33+ PyProxyClient (
34+ base_url = "http://localhost:5000" ,
35+ username = None ,
36+ password = "password" ,
37+ )
2538
2639 def test_missing_password (self ):
2740 with self .assertRaises (PyProxyConfigurationError ):
28- PyProxyClient (base_url = "http://localhost:5000" , username = "admin" , password = None )
41+ PyProxyClient (
42+ base_url = "http://localhost:5000" ,
43+ username = "admin" ,
44+ password = None ,
45+ )
2946
30- @patch (' pyproxy_sdk.client.requests.get' )
47+ @patch (" pyproxy_sdk.client.requests.get" )
3148 def test_get_status_success (self , mock_get ):
3249 mock_response = Mock ()
3350 mock_response .ok = True
@@ -37,7 +54,7 @@ def test_get_status_success(self, mock_get):
3754 result = self .client .get_status ()
3855 self .assertEqual (result , {"status" : "ok" })
3956
40- @patch (' pyproxy_sdk.client.requests.get' )
57+ @patch (" pyproxy_sdk.client.requests.get" )
4158 def test_server_error (self , mock_get ):
4259 mock_response = Mock ()
4360 mock_response .ok = False
@@ -48,7 +65,7 @@ def test_server_error(self, mock_get):
4865 with self .assertRaises (PyProxyServerError ):
4966 self .client .get_status ()
5067
51- @patch (' pyproxy_sdk.client.requests.post' )
68+ @patch (" pyproxy_sdk.client.requests.post" )
5269 def test_add_filtering_already_exists (self , mock_post ):
5370 mock_response = Mock ()
5471 mock_response .ok = False
@@ -59,7 +76,7 @@ def test_add_filtering_already_exists(self, mock_post):
5976 with self .assertRaises (PyProxyAlreadyExists ):
6077 self .client .add_filtering ("domain" , "example.com" )
6178
62- @patch (' pyproxy_sdk.client.requests.delete' )
79+ @patch (" pyproxy_sdk.client.requests.delete" )
6380 def test_delete_filtering_not_found (self , mock_delete ):
6481 mock_response = Mock ()
6582 mock_response .ok = False
@@ -70,7 +87,7 @@ def test_delete_filtering_not_found(self, mock_delete):
7087 with self .assertRaises (PyProxyNotFound ):
7188 self .client .delete_filtering ("domain" , "example.com" )
7289
73- @patch (' pyproxy_sdk.client.requests.post' )
90+ @patch (" pyproxy_sdk.client.requests.post" )
7491 def test_invalid_input (self , mock_post ):
7592 mock_response = Mock ()
7693 mock_response .ok = False
@@ -81,5 +98,6 @@ def test_invalid_input(self, mock_post):
8198 with self .assertRaises (PyProxyInvalidInput ):
8299 self .client .add_filtering ("domain" , "" )
83100
84- if __name__ == '__main__' :
101+
102+ if __name__ == "__main__" :
85103 unittest .main ()
0 commit comments