Added a simple unit test and the test framework
This commit is contained in:
parent
41afba7fff
commit
5509f7d1c8
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
28
tests/test_notification.py
Normal file
28
tests/test_notification.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"""Tests the notification class."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
from mon_notification import notification
|
||||||
|
|
||||||
|
def test_json():
|
||||||
|
"""Test the to_json method to verify it behaves as expected.
|
||||||
|
"""
|
||||||
|
alarm = {'alarmId': 'alarmId',
|
||||||
|
'alarmName': 'alarmName',
|
||||||
|
'timestamp': 'timestamp',
|
||||||
|
'stateChangeReason': 'stateChangeReason',
|
||||||
|
'newState': 'newState',
|
||||||
|
'tenantId': 'tenantId'}
|
||||||
|
test_notification = notification.Notification('ntype', 'src_partition', 'src_offset', 'name', 'address', alarm)
|
||||||
|
|
||||||
|
expected_dict = {u'name': u'name',
|
||||||
|
u'notification_timestamp': None,
|
||||||
|
u'tenant_id': u'tenantId',
|
||||||
|
u'alarm_name': u'alarmName',
|
||||||
|
u'alarm_id': u'alarmId',
|
||||||
|
u'state': u'newState',
|
||||||
|
u'alarm_timestamp': u'timestamp',
|
||||||
|
u'address': u'address',
|
||||||
|
u'message': u'stateChangeReason'}
|
||||||
|
# Compare as dicts so ordering is not an issue
|
||||||
|
assert json.loads(test_notification.to_json()) == expected_dict
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user