diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/README.md b/tests/manual/README.md similarity index 100% rename from test/README.md rename to tests/manual/README.md diff --git a/test/invalid.json b/tests/manual/invalid.json similarity index 100% rename from test/invalid.json rename to tests/manual/invalid.json diff --git a/test/no-op.json b/tests/manual/no-op.json similarity index 100% rename from test/no-op.json rename to tests/manual/no-op.json diff --git a/test/notify.json b/tests/manual/notify.json similarity index 100% rename from test/notify.json rename to tests/manual/notify.json diff --git a/test/sample_notifications.sql b/tests/manual/sample_notifications.sql similarity index 100% rename from test/sample_notifications.sql rename to tests/manual/sample_notifications.sql diff --git a/tests/test_notification.py b/tests/test_notification.py new file mode 100644 index 0000000..48785fc --- /dev/null +++ b/tests/test_notification.py @@ -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 +