Added a simple unit test and the test framework

This commit is contained in:
Tim Kuhlman 2014-03-20 09:52:19 -06:00
parent 41afba7fff
commit 5509f7d1c8
7 changed files with 28 additions and 0 deletions

0
tests/__init__.py Normal file
View File

View 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