Exemplo n.º 1
0
def test_add_node():
    root = _create_filled_tree()

    sub_node = StructuredDataNode()
    sub_node.add_attributes({"sn0": "SN 0", "sn1": "SN 1"})
    sub_node.add_table([
        {
            "sn0": "SN 00",
            "sn1": "SN 01"
        },
        {
            "sn0": "SN 10",
            "sn1": "SN 11"
        },
    ])

    node = root.get_node(["path", "to", "nta"]).add_node("node", sub_node)

    # Do not modify orig node.
    assert sub_node.attributes.path == tuple()
    assert sub_node.table.path == tuple()
    assert sub_node.path == tuple()

    assert node.attributes.path == tuple(["path", "to", "nta", "node"])
    assert node.table.path == tuple(["path", "to", "nta", "node"])
    assert node.path == tuple(["path", "to", "nta", "node"])

    assert not root.is_empty()
    assert root.count_entries() == 18
Exemplo n.º 2
0
def test_add_table():
    path = ("path-to", "node")
    key_columns = ["key-0"]
    retentions: TableRetentions = {
        ("Value 0", ): {
            "key-1": RetentionIntervals(1, 2, 3)
        },
    }

    node = StructuredDataNode(name="node", path=path)
    table = Table(
        key_columns=key_columns,
        retentions=retentions,
    )
    node.add_table(table)

    assert node.table.path == path
    assert node.table.key_columns == key_columns
    assert node.table.retentions == retentions