Skip to content

Commit c176f07

Browse files
MichelMoriniauxqiluo-msft
authored andcommitted
Error on line 353 of rfc1213.py (sonic-net#76)
1 parent 8a9fd25 commit c176f07

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/sonic_ax_impl/mibs/ietf/rfc1213.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_speed_bps(self, sub_id):
350350

351351
speed = int(entry.get(b"speed", 0))
352352
# speed is reported in Mbps in the db
353-
return min(RFC1213_MAX_SPEED, speed * 1000000)
353+
return min(self.RFC1213_MAX_SPEED, speed * 1000000)
354354

355355
class InterfacesMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.2'):
356356
"""

tests/test_hc_interfaces.py

+21
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,24 @@ def test_no_speed(self):
145145
self.assertEqual(value0.type_, ValueType.GAUGE_32)
146146
self.assertEqual(str(value0.name), str(ObjectIdentifier(12, 0, 1, 0, (1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 15, 121))))
147147
self.assertEqual(value0.data, 40000)
148+
149+
def test_no_description(self):
150+
"""
151+
For a port with no speed in the db the result should be 40000
152+
"""
153+
oid = ObjectIdentifier(12, 0, 0, 0, (1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 18, 113))
154+
get_pdu = GetNextPDU(
155+
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0),
156+
oids=[oid]
157+
)
158+
159+
encoded = get_pdu.encode()
160+
response = get_pdu.make_response(self.lut)
161+
print(response)
162+
163+
n = len(response.values)
164+
# self.assertEqual(n, 7)
165+
value0 = response.values[0]
166+
self.assertEqual(value0.type_, ValueType.OCTET_STRING)
167+
self.assertEqual(str(value0.name), str(ObjectIdentifier(12, 0, 1, 0, (1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 18, 117))))
168+
self.assertEqual(str(value0.data), '')

0 commit comments

Comments
 (0)