Skip to content

Commit add3da1

Browse files
yt-msMidnighter
authored andcommitted
fix(DeploymentNode): interaction style is tag-based so does not replicate onto deployment node relationships
1 parent 074b0a2 commit add3da1

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/structurizr/model/relationship.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def __init__(
9494
self._destination_id = destination_id
9595
self.description = description
9696
self.technology = technology
97-
self.interaction_style = interaction_style
9897
self.linked_relationship_id = linked_relationship_id
9998

10099
self.tags.add(Tags.RELATIONSHIP)
@@ -124,9 +123,9 @@ def destination_id(self) -> str:
124123
def interaction_style(self) -> str:
125124
"""Return the interaction style of the relationship based on its tags."""
126125
return (
127-
InteractionStyle.Synchronous
128-
if Tags.SYNCHRONOUS in self.tags
129-
else InteractionStyle.Asynchronous
126+
InteractionStyle.Asynchronous
127+
if Tags.ASYNCHRONOUS in self.tags
128+
else InteractionStyle.Synchronous
130129
)
131130

132131
@classmethod

tests/integration/test_relationship_replication.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ def test_replication_adds_relationships_in_the_same_environment(empty_model: Mod
7272
live_deployment_node.add_container(container3)
7373
live_deployment_node.add_software_system(system4)
7474

75+
# Note that because the tags are cleared the interaction style won't be replicated
7576
assert len(container_instance1.relationships) == 1
7677
relationship = next(iter(container_instance1.relationships))
7778
assert relationship.source is container_instance1
7879
assert relationship.destination is container_instance2
7980
assert relationship.description == "Uses 1"
8081
assert relationship.technology == "Technology 1"
81-
assert relationship.interaction_style == InteractionStyle.Synchronous
8282
assert relationship.tags == set()
8383

8484
assert len(container_instance2.relationships) == 1
@@ -87,7 +87,6 @@ def test_replication_adds_relationships_in_the_same_environment(empty_model: Mod
8787
assert relationship.destination is container_instance3
8888
assert relationship.description == "Uses 2"
8989
assert relationship.technology == "Technology 2"
90-
assert relationship.interaction_style == InteractionStyle.Asynchronous
9190
assert relationship.tags == set()
9291

9392
assert len(container_instance3.relationships) == 1
@@ -96,7 +95,6 @@ def test_replication_adds_relationships_in_the_same_environment(empty_model: Mod
9695
assert relationship.destination is system_instance
9796
assert relationship.description == "Uses"
9897
assert relationship.technology == ""
99-
assert relationship.interaction_style == InteractionStyle.Synchronous
10098
assert relationship.tags == set()
10199

102100

tests/unit/model/test_relationship.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
"""Ensure the expected behaviour of relationships."""
1717

18-
1918
import pytest
2019

20+
from structurizr.model.interaction_style import InteractionStyle
2121
from structurizr.model.relationship import Relationship
22+
from structurizr.model.tags import Tags
2223

2324

2425
@pytest.mark.parametrize(
@@ -30,3 +31,16 @@ def test_relationship_init(attributes):
3031
relationship = Relationship(**attributes)
3132
for attr, expected in attributes.items():
3233
assert getattr(relationship, attr) == expected
34+
35+
36+
def test_relationship_interaction_style():
37+
"""Test that interaction style is consistent with tags."""
38+
relationship = Relationship(interaction_style=InteractionStyle.Synchronous)
39+
assert Tags.SYNCHRONOUS in relationship.tags
40+
assert Tags.ASYNCHRONOUS not in relationship.tags
41+
assert relationship.interaction_style == InteractionStyle.Synchronous
42+
43+
relationship = Relationship(interaction_style=InteractionStyle.Asynchronous)
44+
assert Tags.SYNCHRONOUS not in relationship.tags
45+
assert Tags.ASYNCHRONOUS in relationship.tags
46+
assert relationship.interaction_style == InteractionStyle.Asynchronous

0 commit comments

Comments
 (0)