aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_snmptrapd.py
diff options
context:
space:
mode:
authorLadue, David (dl3158) <dl3158@att.com>2019-03-21 18:30:01 -0400
committerLadue, David (dl3158) <dl3158@att.com>2019-03-21 18:32:56 -0400
commitdecf06eb401587c22ede29fbf3da958ac166a638 (patch)
tree8d13f36fd0a531dec329b82b9cb01063ec540b08 /tests/test_snmptrapd.py
parent8e12680f279f50fc7a1ca01e66c003f6059ae754 (diff)
increase pytest coverage4.0.0-ONAPdublin
Change-Id: I871f5fc3182e0a21b3b4c6d6e033abf8730c8d10 Issue-ID: DCAEGEN2-1264 Signed-off-by: Ladue, David (dl3158) <dl3158@att.com>
Diffstat (limited to 'tests/test_snmptrapd.py')
-rw-r--r--tests/test_snmptrapd.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_snmptrapd.py b/tests/test_snmptrapd.py
index 85681ea..9dc92c0 100644
--- a/tests/test_snmptrapd.py
+++ b/tests/test_snmptrapd.py
@@ -150,5 +150,29 @@ class test_snmptrapd(unittest.TestCase):
result = errorIndication
self.assertEqual(result, None)
+ def test_add_varbind_to_json(self):
+
+ # init vars
+ tds.init()
+ tds.trap_dict["notify OID"] = ".1.2.3.4.5.6.7.8"
+ tds.trap_dict["protocol version"] = "v2c"
+
+ # varbinds=[(ObjectName('1.3.6.1.2.1.1.3.0'), TimeTicks(0)), (ObjectName('1.3.6.1.6.3.1.1.4.1.0'), ObjectIdentifier('1.3.6.1.4.1.74.2.46.12.1.1')), (ObjectName('1.3.6.1.4.1.74.2.46.12.1.1.1'), OctetString(b'ucsnmp heartbeat - ignore')), (ObjectName('1.3.6.1.4.1.74.2.46.12.1.1.2'), OctetString(b'Thu Mar 21 15:46:58 2019'))]
+
+ # vb=(ObjectName('1.3.6.1.4.1.74.2.46.12.1.1.1'), OctetString(b'ucsnmp heartbeat - ignore'))
+
+ self.assertEqual(snmptrapd.add_varbind_to_json(0,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 0)
+ self.assertEqual(snmptrapd.add_varbind_to_json(1,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 0)
+ self.assertEqual(snmptrapd.add_varbind_to_json(2,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 1)
+ self.assertEqual(snmptrapd.add_varbind_to_json(3,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 1)
+
+ # init vars
+ tds.init()
+ tds.trap_dict["notify OID"] = ".1.2.3.4.5.6.7.8"
+ tds.trap_dict["protocol version"] = "v1"
+
+ self.assertEqual(snmptrapd.add_varbind_to_json(0,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 0)
+ self.assertEqual(snmptrapd.add_varbind_to_json(5,ObjectIdentifier('.1.2.3.4'), 'OctetString', OctetString(b'Thu Mar 21 15:46:58 2019')), 1)
+
if __name__ == '__main__':
unittest.main()