def test_dict_children_container_schema_serialization():
    dccs = core.DictChildrenContainerSchema(foo=core.ListChildrenContainer, bar=core.ChildContainer)
    node = tn.AddConstantNode("hello")
    in_map = {"foo": [node, node], "bar": node}
    cc1 = dccs(in_map)
    cc2 = core.children_container_from_data(core.children_container_to_data(cc1))

    nt.assert_equal(cc1.__class__, cc2.__class__)
    nt.assert_equal(cc1.__dict__, cc2.__dict__)
def test_list_children_container():
    # test to_data
    cc = core.ListChildrenContainer([])
    nt.assert_equal([], cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(dict(children_container_key="list", children_container_data=[]), as_data)

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.ListChildrenContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))
def test_dict_children_container():
    # test to_data
    cc = core.DictChildrenContainer({})
    nt.assert_equal({}, cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(dict(children_container_key="dict", children_container_data={}), as_data)

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.DictChildrenContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))
def test_dict_children_container_schema_serialization():
    dccs = core.DictChildrenContainerSchema(
        foo=core.ListChildrenContainer,
        bar=core.ChildContainer,
    )
    node = tn.AddConstantNode("hello")
    in_map = {"foo": [node, node], "bar": node}
    cc1 = dccs(in_map)
    cc2 = core.children_container_from_data(
        core.children_container_to_data(cc1))

    nt.assert_equal(cc1.__class__, cc2.__class__)
    nt.assert_equal(cc1.__dict__, cc2.__dict__)
def test_nodes_and_edges_children_container():
    # test to_data
    cc = core.NodesAndEdgesContainer([[], []])
    nt.assert_equal({"nodes": [], "edges": []}, cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(
        dict(children_container_key="nodes_and_edges", children_container_data={"nodes": [], "edges": []}), as_data
    )

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.NodesAndEdgesContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))
def test_list_children_container():
    # test to_data
    cc = core.ListChildrenContainer([])
    nt.assert_equal([], cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(
        dict(
            children_container_key="list",
            children_container_data=[],
        ), as_data)

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.ListChildrenContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))
def test_dict_children_container():
    # test to_data
    cc = core.DictChildrenContainer({})
    nt.assert_equal({}, cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(
        dict(
            children_container_key="dict",
            children_container_data={},
        ), as_data)

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.DictChildrenContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))
def test_nodes_and_edges_children_container():
    # test to_data
    cc = core.NodesAndEdgesContainer([[], []])
    nt.assert_equal({"nodes": [], "edges": []}, cc.to_data())

    # test children_container_to_data
    as_data = core.children_container_to_data(cc)
    nt.assert_equal(
        dict(children_container_key="nodes_and_edges",
             children_container_data={
                 "nodes": [],
                 "edges": []
             }), as_data)

    # test back and forth
    cc2 = core.children_container_from_data(as_data)
    nt.assert_is_instance(cc2, core.NodesAndEdgesContainer)
    nt.assert_equal(as_data, core.children_container_to_data(cc2))