Skip to content

Commit b2eac5b

Browse files
committed
updated unit-tests according to the latest changes
1 parent aca9fc4 commit b2eac5b

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

tests/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class MockBasicAuth():
8181
class MockSessionConn():
8282
def __init__(self):
8383
self._ssl = None
84+
self.closed = False
85+
def close(self):
86+
self.closed = True
8487

8588
class MockSession():
8689
def __init__(self, exception=None):

tests/test_zabbix_aioapi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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

tests/test_zabbix_api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)