@@ -64,3 +64,24 @@ def test_expression_add():
6464 { 'p' : 'snmp.test123.asdf.3' , 'v' : 62500.0 },
6565 ]
6666 assert _apply_expression_to_results (results , methods , expression , output_path ) == expected_result
67+
68+ def test_snmpwalk_missing_value ():
69+ results = [
70+ [
71+ SNMPVariable (oid = '1.3.6.1.4.1.2021.13.16.2.1.3' , oid_index = '1' , value = 60000 , snmp_type = 'GAUGE' ),
72+ SNMPVariable (oid = '1.3.6.1.4.1.2021.13.16.2.1.3' , oid_index = '2' , value = 61000 , snmp_type = 'GAUGE' ),
73+ SNMPVariable (oid = '1.3.6.1.4.1.2021.13.16.2.1.3' , oid_index = '3' , value = 62000 , snmp_type = 'GAUGE' ),
74+ ],
75+ [
76+ SNMPVariable (oid = '1.3.6.1.4.1.2021.13.16.2.2.2' , oid_index = '1' , value = 10 , snmp_type = 'GAUGE' ),
77+ SNMPVariable (oid = '1.3.6.1.4.1.2021.13.16.2.2.2' , oid_index = '2' , value = 10 , snmp_type = 'GAUGE' ),
78+ ],
79+ ]
80+ methods = ['walk' if isinstance (x , list ) else 'get' for x in results ]
81+ expression = '$1 / $2'
82+ output_path = 'snmp.test123.asdf'
83+ expected_result = [
84+ { 'p' : 'snmp.test123.asdf.1' , 'v' : 6000.0 },
85+ { 'p' : 'snmp.test123.asdf.2' , 'v' : 6100.0 },
86+ ]
87+ assert _apply_expression_to_results (results , methods , expression , output_path ) == expected_result
0 commit comments