forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix entPhysicalSerialNum OID (sonic-net#63)
* Fix entPhysicalSerialNum OID Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com> * Add unit test for PhysicalTableMIB Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
- Loading branch information
1 parent
20f3bce
commit 9a7a70c
Showing
4 changed files
with
77 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"DEVICE_METADATA|localhost": { | ||
"chassis_serial_number": "SAMPLETESTSN" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import sys | ||
|
||
modules_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
sys.path.insert(0, os.path.join(modules_path, 'src')) | ||
|
||
from unittest import TestCase | ||
|
||
# noinspection PyUnresolvedReferences | ||
import tests.mock_tables.dbconnector | ||
|
||
from ax_interface.mib import MIBTable | ||
from ax_interface.pdu import PDUHeader | ||
from ax_interface.pdu_implementations import GetPDU, GetNextPDU | ||
from ax_interface import ValueType | ||
from ax_interface.encodings import ObjectIdentifier | ||
from ax_interface.constants import PduTypes | ||
from sonic_ax_impl.mibs.ietf import rfc4363 | ||
from sonic_ax_impl.main import SonicMIB | ||
|
||
class TestSonicMIB(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.lut = MIBTable(SonicMIB) | ||
|
||
def test_getnextpdu_entPhysicalClass(self): | ||
get_pdu = GetNextPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=( | ||
ObjectIdentifier(12, 0, 0, 0, (1, 3, 6, 1, 2, 1, 47, 1, 1, 1, 1, 5)), | ||
) | ||
) | ||
|
||
encoded = get_pdu.encode() | ||
response = get_pdu.make_response(self.lut) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(12, 0, 1, 0, (1, 3, 6, 1, 2, 1, 47, 1, 1, 1, 1, 5, 1)))) | ||
self.assertEqual(value0.type_, ValueType.INTEGER) | ||
self.assertEqual(value0.data, 3) | ||
|
||
def test_getnextpdu_entPhysicalSerialNum(self): | ||
get_pdu = GetNextPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=( | ||
ObjectIdentifier(20, 0, 0, 0, (1, 3, 6, 1, 2, 1, 47, 1, 1, 1, 1, 11)), | ||
) | ||
) | ||
|
||
encoded = get_pdu.encode() | ||
response = get_pdu.make_response(self.lut) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(12, 0, 1, 0, (1, 3, 6, 1, 2, 1, 47, 1, 1, 1, 1, 11, 1)))) | ||
self.assertEqual(value0.type_, ValueType.OCTET_STRING) | ||
self.assertEqual(str(value0.data), "SAMPLETESTSN") |