From 701ab640f1d99f955ba0b14ae5bde49a3b7887f4 Mon Sep 17 00:00:00 2001 From: "Ladue, David (dl3158)" Date: Wed, 22 Aug 2018 17:01:59 -0400 Subject: added test coverage Change-Id: Ie8310bab09ce329e499263f07b3ab2d3a8969727 Issue-ID: DCAEGEN2-630 Signed-off-by: Ladue, David (dl3158) --- tests/test_snmptrapd.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/test_snmptrapd.py') diff --git a/tests/test_snmptrapd.py b/tests/test_snmptrapd.py index 941c0ae..85681ea 100644 --- a/tests/test_snmptrapd.py +++ b/tests/test_snmptrapd.py @@ -10,6 +10,9 @@ import trapd_runtime_pid import trapd_io import trapd_get_cbs_config +from pysnmp.hlapi import * +from pysnmp import debug + class test_snmptrapd(unittest.TestCase): """ Test the save_pid mod @@ -123,5 +126,29 @@ class test_snmptrapd(unittest.TestCase): # open eelf logs trapd_io.open_eelf_logs() + def test_v1_trap_receipt(self): + """ + Test receiving traps + """ + + # init vars + tds.init() + + # request load of CBS data + os.environ.update(CBS_SIM_JSON='/tmp/opt/app/snmptrap/etc/snmptrapd.json') + trapd_get_cbs_config.get_cbs_config() + + errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(), + CommunityData('not_public'), + UdpTransportTarget(('localhost', 6162)), + ContextData(), + 'trap', + [ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.1'), OctetString('test trap - ignore')), + ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.2'), OctetString('ONAP pytest trap'))]) + ) + + result = errorIndication + self.assertEqual(result, None) + if __name__ == '__main__': unittest.main() -- cgit 1.2.3-korg