Example #1
0
def test_model_add_relationship_twice_ignored(empty_model: Model):
    """Ensure that adding an existing relationship to the Model makes no difference."""
    sys1 = empty_model.add_software_system(name="sys1")
    sys2 = empty_model.add_software_system(name="sys2")
    relationship = empty_model.add_relationship(source=sys1, destination=sys2)
    assert set(empty_model.get_relationships()) == {relationship}
    empty_model.add_relationship(relationship)
    assert set(empty_model.get_relationships()) == {relationship}
Example #2
0
def test_adding_relationship_via_uses_adds_to_elements():
    """Ensure uses() adds relationships to the model and elements."""
    model = Model()
    sys1 = model.add_software_system(name="sys1")
    sys2 = model.add_software_system(name="sys2")

    relationship = sys1.uses(sys2, "uses")
    assert sys1.relationships == {relationship}
    assert set(sys1.get_relationships()) == {relationship}
    assert set(model.get_relationships()) == {relationship}
    assert sys2.relationships == set()  # relationships only contains outbound
    assert set(sys2.get_relationships()) == {relationship}
Example #3
0
def test_adding_relationship_to_model_adds_to_element():
    """Ensure relationships are added to elements.

    Make sure that when a relationship is added via Model.add_relationship it also
    gets added to the elements.
    """
    model = Model()
    sys1 = model.add_software_system(name="sys1")
    sys2 = model.add_software_system(name="sys2")

    relationship = model.add_relationship(source=sys1,
                                          destination=sys2,
                                          description="uses")
    assert sys1.relationships == {relationship}
    assert set(sys1.get_relationships()) == {relationship}
    assert set(model.get_relationships()) == {relationship}
    assert sys2.relationships == set()  # relationships only contains outbound
    assert set(sys2.get_relationships()) == {relationship}