GeezerVison is showing github.com — schema: add store_only parameter to parse_data_dict · CESNET/libyang-python@1afc2a6
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: libyang/schema.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -241,6 +241,7 @@ def parse_data_dict( |
241 | 241 | rpc: bool = False, |
242 | 242 | rpcreply: bool = False, |
243 | 243 | notification: bool = False, |
| 244 | + store_only: bool = False, |
244 | 245 | ) -> "libyang.data.DNode": |
245 | 246 | """ |
246 | 247 | Convert a python dictionary to a DNode object following the schema of this |
@@ -276,6 +277,7 @@ def parse_data_dict( |
276 | 277 | rpc=rpc, |
277 | 278 | rpcreply=rpcreply, |
278 | 279 | notification=notification, |
| 280 | + store_only=store_only, |
279 | 281 | ) |
280 | 282 |
|
281 | 283 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: tests/test_data.py +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1112,3 +1112,22 @@ def test_dnode_builtin_plugins_only(self): |
1112 | 1112 | self.assertIsInstance(dnode, DLeaf) |
1113 | 1113 | self.assertEqual(dnode.value(), "test") |
1114 | 1114 | dnode.free() |
| 1115 | + |
| 1116 | + def test_merge_store_only(self): |
| 1117 | + MAIN = {"yolo-nodetypes:test1": 50} |
| 1118 | + module = self.ctx.load_module("yolo-nodetypes") |
| 1119 | + dnode = module.parse_data_dict(MAIN, validate=False, store_only=True) |
| 1120 | + self.assertIsInstance(dnode, DLeaf) |
| 1121 | + self.assertEqual(dnode.value(), 50) |
| 1122 | + dnode.free() |
| 1123 | + |
| 1124 | + def test_merge_builtin_plugins_only(self): |
| 1125 | + MAIN = {"yolo-nodetypes:ip-address": "test"} |
| 1126 | + self.tearDown() |
| 1127 | + gc.collect() |
| 1128 | + self.ctx = Context(YANG_DIR, builtin_plugins_only=True) |
| 1129 | + module = self.ctx.load_module("yolo-nodetypes") |
| 1130 | + dnode = module.parse_data_dict(MAIN, validate=False, store_only=True) |
| 1131 | + self.assertIsInstance(dnode, DLeaf) |
| 1132 | + self.assertEqual(dnode.value(), "test") |
| 1133 | + dnode.free() |