2929
3030
3131class TestClient (unittest .TestCase ):
32-
3332 def setUp (self ):
34- self .url = ' some api url'
35- self .client = kanboard .Client (self .url , ' username' , ' password' )
33+ self .url = " some api url"
34+ self .client = kanboard .Client (self .url , " username" , " password" )
3635 self .request , self .urlopen = self ._create_mocks ()
3736
3837 def ignore_warnings (test_func ):
3938 def do_test (self , * args , ** kwargs ):
4039 with warnings .catch_warnings ():
4140 warnings .simplefilter ("ignore" )
4241 test_func (self , * args , ** kwargs )
42+
4343 return do_test
4444
4545 def test_api_call (self ):
4646 body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
4747 self .urlopen .return_value .read .return_value = body
4848 self .assertEqual (True , self .client .remote_procedure ())
49- self .request .assert_called_once_with (self .url ,
50- data = mock .ANY ,
51- headers = mock .ANY )
49+ self .request .assert_called_once_with (self .url , data = mock .ANY , headers = mock .ANY )
5250
5351 def test_custom_auth_header (self ):
54- self .client ._auth_header = ' X-Auth-Header'
52+ self .client ._auth_header = " X-Auth-Header"
5553 body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
5654 self .urlopen .return_value .read .return_value = body
5755 self .assertEqual (True , self .client .remote_procedure ())
58- self .request .assert_called_once_with (self .url ,
59- data = mock .ANY ,
60- headers = mock .ANY )
56+ self .request .assert_called_once_with (self .url , data = mock .ANY , headers = mock .ANY )
6157 _ , kwargs = self .request .call_args
62- assert kwargs [' headers' ][ ' X-Auth-Header' ] == ' dXNlcm5hbWU6cGFzc3dvcmQ='
58+ assert kwargs [" headers" ][ " X-Auth-Header" ] == " dXNlcm5hbWU6cGFzc3dvcmQ="
6359
6460 def test_http_error (self ):
6561 self .urlopen .side_effect = Exception ()
@@ -70,7 +66,7 @@ def test_application_error(self):
7066 body = b'{"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 123}'
7167 self .urlopen .return_value .read .return_value = body
7268
73- with self .assertRaises (kanboard .ClientError , msg = ' Internal error' ):
69+ with self .assertRaises (kanboard .ClientError , msg = " Internal error" ):
7470 self .client .remote_procedure ()
7571
7672 def test_async_method_call_recognised (self ):
@@ -98,6 +94,6 @@ def test_async_call_generates_coro(self):
9894
9995 @staticmethod
10096 def _create_mocks ():
101- request_patcher = mock .patch (' urllib.request.Request' )
102- urlopen_patcher = mock .patch (' urllib.request.urlopen' )
97+ request_patcher = mock .patch (" urllib.request.Request" )
98+ urlopen_patcher = mock .patch (" urllib.request.urlopen" )
10399 return request_patcher .start (), urlopen_patcher .start ()
0 commit comments