File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ class MockBasicAuth():
8181class MockSessionConn ():
8282 def __init__ (self ):
8383 self ._ssl = None
84+ self .closed = False
85+ def close (self ):
86+ self .closed = True
8487
8588class MockSession ():
8689 def __init__ (self , exception = None ):
Original file line number Diff line number Diff line change @@ -289,8 +289,10 @@ async def test__prepare_request(self):
289289 params = {'user' : DEFAULT_VALUES ['user' ], 'password' : DEFAULT_VALUES ['password' ]},
290290 need_auth = True
291291 )
292- self .assertEqual (req .get ('auth' ), DEFAULT_VALUES ['token' ],
293- "unexpected auth request parameter, must be: " + DEFAULT_VALUES ['token' ])
292+ self .assertEqual (req .get ('auth' ), None ,
293+ "unexpected auth request parameter, must be: None" )
294+ self .assertEqual (headers .get ('Authorization' ), 'Bearer ' + DEFAULT_VALUES ['token' ],
295+ "unexpected Authorization header, must be: Bearer " + DEFAULT_VALUES ['token' ])
294296 self .zapi .client_session .del_auth ()
295297 await self .zapi .logout ()
296298
Original file line number Diff line number Diff line change @@ -50,10 +50,13 @@ def mock_urlopen(*args, **kwargs):
5050 ul ,
5151 urlopen = mock_urlopen ):
5252
53- zapi = ZabbixAPI (
54- http_user = DEFAULT_VALUES ['user' ],
55- http_password = DEFAULT_VALUES ['password' ]
56- )
53+ with self .assertRaises (APINotSupported ,
54+ msg = "expected APINotSupported exception hasn't been raised" ):
55+ ZabbixAPI (
56+ http_user = DEFAULT_VALUES ['user' ],
57+ http_password = DEFAULT_VALUES ['password' ]
58+ )
59+ zapi = ZabbixAPI ()
5760 with self .assertRaises (ProcessingError ,
5861 msg = "expected ProcessingError exception hasn't been raised" ):
5962 zapi .hosts .get ()
@@ -160,7 +163,9 @@ def test_login(self):
160163 ZabbixAPI ,
161164 send_api_request = common .mock_send_sync_request ):
162165
163- zapi = ZabbixAPI (http_user = DEFAULT_VALUES ['user' ], http_password = DEFAULT_VALUES ['password' ])
166+ with self .assertRaises (APINotSupported , msg = "expected APINotSupported exception hasn't been raised" ):
167+ ZabbixAPI (http_user = DEFAULT_VALUES ['user' ], http_password = DEFAULT_VALUES ['password' ])
168+ zapi = ZabbixAPI ()
164169
165170 with self .assertRaises (TypeError , msg = "expected TypeError exception hasn't been raised" ):
166171 zapi = ZabbixAPI ()
You can’t perform that action at this time.
0 commit comments