Skip to content
Snippets Groups Projects
Commit 3fe7a07d authored by Ladislav Lhotka's avatar Ladislav Lhotka
Browse files

Handle notification statement.

parent b97fc031
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -50,4 +50,11 @@ module testb {
}
}
}
notification noA {
leaf leafO {
type boolean;
default "true";
}
}
}
......@@ -10,7 +10,7 @@ def contents(*filenames):
setup(
name = "yangson",
packages = ["yangson"],
version = "0.1.31",
version = "0.1.32",
description = "Library for working with YANG schemas and data",
author = "Ladislav Lhotka",
author_email = "lhotka@nic.cz",
......
......@@ -45,6 +45,7 @@ def test_schema(data_model):
llc = data_model.get_schema_node("/testb:rpcA/output/llistC")
ll = lsta.get_schema_descendant(Context.path2route(
"test:contD/acA/output/leafL"))
lo = data_model.get_schema_node("/testb:noA/leafO")
assert la.parent == lb.parent == chb.parent == ca
assert ll.parent.name == "output"
assert (axa.mandatory == la.mandatory == cb.mandatory == cc.mandatory ==
......@@ -61,6 +62,7 @@ def test_schema(data_model):
assert ld.type.default == 111
assert lla.default == [42, 54]
assert lla.type.default == 11
assert lo.default == True
assert la.type.parse_value("99") == 99
with pytest.raises(YangTypeError):
ld.type.parse_value("99")
......@@ -73,3 +75,4 @@ def test_schema(data_model):
assert lsta.get_schema_descendant(lsta.keys[1:]).name == "leafF"
assert lsta.get_schema_descendant(lsta.unique[0][0]).name == "leafG"
assert data_model.get_data_node("/test:contA/listA/contD/leafM") is None
assert data_model.get_data_node("/testb:noA/leafO") is None
......@@ -110,6 +110,7 @@ class SchemaNode:
"mandatory": "_mandatory_stmt",
"max-elements": "_max_elements_stmt",
"min-elements": "_min_elements_stmt",
"notification": "_notification_stmt",
"output": "_output_stmt",
"ordered-by": "_ordered_by_stmt",
"presence": "_presence_stmt",
......@@ -281,6 +282,11 @@ class InternalNode(SchemaNode):
if Context.if_features(stmt, mid):
self._handle_child(RpcActionNode(), stmt, mid)
def _notification_stmt(self, stmt: Statement, mid: ModuleId) -> None:
"""Handle notification statement."""
if Context.if_features(stmt, mid):
self._handle_child(NotificationNode(), stmt, mid)
def _anydata_stmt(self, stmt: Statement, mid: ModuleId) -> None:
"""Handle anydata statement."""
if Context.if_features(stmt, mid):
......@@ -595,6 +601,19 @@ class OutputNode(InternalNode):
def _tree_line_prefix(self) -> str:
return super()._tree_line_prefix() + "ro"
class NotificationNode(InternalNode):
"""Notification node."""
def _tree_line_prefix(self) -> str:
return super()._tree_line_prefix() + "-n"
def state_roots(self) -> List[InstanceRoute]:
"""Return a list of routes to descendant state data roots (or self)."""
return []
def _state_roots(self) -> List[SchemaNode]:
return []
class LeafNode(TerminalNode, DataNode):
"""Leaf node."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment