Exemple #1
0
def test_deployment_node_serialization_of_recursive_nodes(model_with_node):
    """Check that nodes within nodes are handled with (de)serialisation."""
    top_node = model_with_node.empty_node
    top_node.add_deployment_node(name="child")

    io = DeploymentNodeIO.from_orm(top_node)
    assert len(io.children) == 1
    assert io.children[0].name == "child"

    new_top_node = DeploymentNode.hydrate(io, model_with_node)
    assert len(new_top_node.children) == 1
    new_child = new_top_node.children[0]
    assert new_child.name == "child"
    assert new_child.parent is new_top_node
Exemple #2
0
def test_deployment_node_serialising_infrastructure_nodes(model_with_node):
    """Test serialisation and deserialisation includes infrastructure nodes."""
    node = model_with_node.empty_node
    node.add_infrastructure_node("infraNode")

    io = DeploymentNodeIO.from_orm(node)

    assert len(io.infrastructure_nodes) == 1
    assert io.infrastructure_nodes[0].id == "id"
    assert io.infrastructure_nodes[0].name == "infraNode"

    node2 = DeploymentNode.hydrate(io, model_with_node)

    assert len(node2.infrastructure_nodes) == 1
    infra_node = node2.infrastructure_nodes[0]
    assert infra_node.name == "infraNode"
    assert infra_node.parent is node2
Exemple #3
0
def test_deployment_node_serialising_software_system(model_with_node):
    """Test serialisation and deserialisation includes container instances."""
    node = model_with_node.empty_node
    system = model_with_node.mock_element
    node.add_software_system(system, replicate_relationships=False)

    io = DeploymentNodeIO.from_orm(node)

    assert len(io.software_system_instances) == 1
    assert io.software_system_instances[0].id == "id"

    node2 = DeploymentNode.hydrate(io, model_with_node)

    assert len(node2.software_system_instances) == 1
    instance = node2.software_system_instances[0]
    assert instance.instance_id == 1
    assert instance.software_system is system
    assert instance.parent is node2
Exemple #4
0
def test_deployment_node_serialising_container(model_with_node):
    """Test serialisation and deserialisation includes container instances."""
    node = model_with_node.empty_node
    container = model_with_node.mock_element
    node.add_container(container, replicate_relationships=False)

    io = DeploymentNodeIO.from_orm(node)

    assert len(io.container_instances) == 1
    assert io.container_instances[0].id == "id"

    node2 = DeploymentNode.hydrate(io, model_with_node)

    assert len(node2.container_instances) == 1
    instance = node2.container_instances[0]
    assert instance.instance_id == 1
    assert instance.container is container
    assert instance.model is model_with_node
    assert instance.parent is node2