Skip to content

Commit 656b67e

Browse files
committed
test: cover unsupported LLDP subtype paths
Signed-off-by: KeshavSM10 <harshavardhanmundada@gmail.com>
1 parent 88793b7 commit 656b67e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

tests/test_lldpSyncDaemon.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,62 @@ def test_invalid_chassis_name(self, mock_check_output):
218218
'''
219219
result = self.daemon.source_update()
220220
self.assertIsNone(result)
221+
222+
def test_unsupported_port_subtype(self):
223+
bad_json = {
224+
"lldp": {
225+
"interface": [
226+
{
227+
"Ethernet1": {
228+
"via": "LLDP",
229+
"rid": "1",
230+
"age": "0 day, 00:00:10",
231+
"chassis": {
232+
"id": {"type": "mac", "value": "aa:bb:cc:dd:ee:ff"}
233+
},
234+
"port": {
235+
"id": {"type": "unhandled", "value": "garbage"},
236+
"ttl": "120"
237+
}
238+
}
239+
}
240+
]
241+
}
242+
}
243+
244+
parsed = self.daemon.parse_update(bad_json)
245+
246+
self.assertIn("Ethernet1", parsed)
247+
self.assertIsNone(parsed["Ethernet1"]["lldp_rem_port_id_subtype"])
248+
self.assertEqual(parsed["Ethernet1"]["lldp_rem_port_id"], None)
249+
250+
def test_unsupported_chassis_subtype(self):
251+
bad_json = {
252+
"lldp": {
253+
"interface": [
254+
{
255+
"Ethernet2": {
256+
"via": "LLDP",
257+
"rid": "1",
258+
"age": "0 day, 00:00:10",
259+
"chassis": {
260+
"id": {"type": "unhandled", "value": "garbage"}
261+
},
262+
"port": {
263+
"id": {"type": "ifname", "value": "Ethernet2"},
264+
"ttl": "120"
265+
}
266+
}
267+
}
268+
]
269+
}
270+
}
271+
272+
parsed = self.daemon.parse_update(bad_json)
273+
274+
self.assertIn("Ethernet2", parsed)
275+
self.assertEqual(parsed["Ethernet2"]["lldp_rem_chassis_id_subtype"], "")
276+
self.assertEqual(parsed["Ethernet2"]["lldp_rem_chassis_id"], "")
221277

222278

223279
def test_changed_interface(self):

0 commit comments

Comments
 (0)