From b282737628d4ba5b21776525fde5a35d48710521 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 10 Oct 2024 17:30:32 +0000 Subject: [PATCH] fix deserialize tests --- src/social_norms_trees/serialize_tree.py | 30 +++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/social_norms_trees/serialize_tree.py b/src/social_norms_trees/serialize_tree.py index e12ba62..930b107 100644 --- a/src/social_norms_trees/serialize_tree.py +++ b/src/social_norms_trees/serialize_tree.py @@ -43,7 +43,35 @@ def serialize_tree(tree, include_children=True): def deserialize_library_element(description: dict): """ Examples: - >>> deserialize_library_element({"type": "Sequence"}) + >>> s = deserialize_library_element({"type": "Sequence", "name": "Sequence 0", "id": "s0"}) + >>> s + + + >>> s.id_ + 's0' + + >>> s.name + 'Sequence 0' + + >>> s.children + [] + + TODO: Implement selectors + >>> deserialize_library_element({"type": "Selector", "name": "Selector 0", "id": "s0"}) + Traceback (most recent call last): + ... + NotImplementedError: node_type=Selector is not implemented + + >>> b = deserialize_library_element({"type": "Behavior", "name": "Behavior 0", "id": "b0"}) + >>> b + + + >>> b.id_ + 'b0' + + >>> b.name + 'Behavior 0' + """ assert isinstance(description["type"], str), (