Skip to content

Commit cccb9d6

Browse files
ishidawatarusamuel-gauthier
authored andcommitted
test: add keyless list test
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 <wataru.ishid@gmail.com> Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
1 parent 097412c commit cccb9d6

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

tests/test_data.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,22 @@ def test_notification_from_dict_module(self):
704704
dnotif.free()
705705
self.assertEqual(json.loads(j), json.loads(self.JSON_NOTIF))
706706

707+
DICT_NOTIF_KEYLESS_LIST = {
708+
"config-change": {"edit": [{"target": "a"}, {"target": "b"}]},
709+
}
710+
711+
def test_data_to_dict_keyless_list(self):
712+
module = self.ctx.get_module("yolo-system")
713+
dnotif = module.parse_data_dict(
714+
self.DICT_NOTIF_KEYLESS_LIST, strict=True, notification=True
715+
)
716+
self.assertIsInstance(dnotif, DNotif)
717+
try:
718+
dic = dnotif.print_dict()
719+
finally:
720+
dnotif.free()
721+
self.assertEqual(dic, self.DICT_NOTIF_KEYLESS_LIST)
722+
707723
XML_DIFF_STATE1 = """<state xmlns="urn:yang:yolo:system">
708724
<hostname>foo</hostname>
709725
<speed>1234</speed>

tests/test_diff.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class DiffTest(unittest.TestCase):
7575
(SNodeAdded, "/yolo-system:alarm-triggered"),
7676
(SNodeAdded, "/yolo-system:alarm-triggered/severity"),
7777
(SNodeAdded, "/yolo-system:alarm-triggered/description"),
78+
(SNodeAdded, "/yolo-system:config-change"),
79+
(SNodeAdded, "/yolo-system:config-change/edit"),
80+
(SNodeAdded, "/yolo-system:config-change/edit/target"),
7881
(EnumRemoved, "/yolo-system:conf/url/proto"),
7982
(EnumRemoved, "/yolo-system:state/url/proto"),
8083
(EnumStatusAdded, "/yolo-system:conf/url/proto"),

tests/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_mod_filepath(self):
5656

5757
def test_mod_iter(self):
5858
children = list(iter(self.module))
59-
self.assertEqual(len(children), 5)
59+
self.assertEqual(len(children), 6)
6060

6161
def test_mod_children_rpcs(self):
6262
rpcs = list(self.module.children(types=(SNode.RPC,)))

tests/yang/yolo/yolo-system.yang

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,12 @@ module yolo-system {
204204
type uint32;
205205
}
206206
}
207+
208+
notification config-change {
209+
list edit {
210+
leaf target {
211+
type string;
212+
}
213+
}
214+
}
207215
}

0 commit comments

Comments
 (0)