Skip to content

Commit

Permalink
test: add keyless list test
Browse files Browse the repository at this point in the history
Keyless list is allowed for operational data. (see RFC7950 7.8.2.) It is
used in ietf-netconf-notifications:netconf-config-change, for example.

It is already supported, but untested, add a test case.

Signed-off-by: Wataru Ishida <[email protected]>
Signed-off-by: Samuel Gauthier <[email protected]>
  • Loading branch information
ishidawataru authored and samuel-gauthier committed Jan 25, 2024
1 parent 097412c commit cccb9d6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,22 @@ def test_notification_from_dict_module(self):
dnotif.free()
self.assertEqual(json.loads(j), json.loads(self.JSON_NOTIF))

DICT_NOTIF_KEYLESS_LIST = {
"config-change": {"edit": [{"target": "a"}, {"target": "b"}]},
}

def test_data_to_dict_keyless_list(self):
module = self.ctx.get_module("yolo-system")
dnotif = module.parse_data_dict(
self.DICT_NOTIF_KEYLESS_LIST, strict=True, notification=True
)
self.assertIsInstance(dnotif, DNotif)
try:
dic = dnotif.print_dict()
finally:
dnotif.free()
self.assertEqual(dic, self.DICT_NOTIF_KEYLESS_LIST)

XML_DIFF_STATE1 = """<state xmlns="urn:yang:yolo:system">
<hostname>foo</hostname>
<speed>1234</speed>
Expand Down
3 changes: 3 additions & 0 deletions tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class DiffTest(unittest.TestCase):
(SNodeAdded, "/yolo-system:alarm-triggered"),
(SNodeAdded, "/yolo-system:alarm-triggered/severity"),
(SNodeAdded, "/yolo-system:alarm-triggered/description"),
(SNodeAdded, "/yolo-system:config-change"),
(SNodeAdded, "/yolo-system:config-change/edit"),
(SNodeAdded, "/yolo-system:config-change/edit/target"),
(EnumRemoved, "/yolo-system:conf/url/proto"),
(EnumRemoved, "/yolo-system:state/url/proto"),
(EnumStatusAdded, "/yolo-system:conf/url/proto"),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_mod_filepath(self):

def test_mod_iter(self):
children = list(iter(self.module))
self.assertEqual(len(children), 5)
self.assertEqual(len(children), 6)

def test_mod_children_rpcs(self):
rpcs = list(self.module.children(types=(SNode.RPC,)))
Expand Down
8 changes: 8 additions & 0 deletions tests/yang/yolo/yolo-system.yang
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,12 @@ module yolo-system {
type uint32;
}
}

notification config-change {
list edit {
leaf target {
type string;
}
}
}
}

0 comments on commit cccb9d6

Please sign in to comment.