Skip to content

Commit

Permalink
fix deserialize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hollandjg committed Oct 10, 2024
1 parent 99cf31e commit b282737
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/social_norms_trees/serialize_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<social_norms_trees.custom_node_library.CustomSequence object at 0x...>
>>> 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
<social_norms_trees.custom_node_library.CustomBehavior object at 0x...>
>>> b.id_
'b0'
>>> b.name
'Behavior 0'
"""
assert isinstance(description["type"], str), (
Expand Down

0 comments on commit b282737

Please sign in to comment.