Skip to content

Commit 4b74da5

Browse files
yt-msMidnighter
authored andcommitted
fix: missing default tags
1 parent b8262d2 commit 4b74da5

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/structurizr/model/container_instance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
StaticStructureElementInstance,
2525
StaticStructureElementInstanceIO,
2626
)
27+
from .tags import Tags
2728

2829

2930
if TYPE_CHECKING:
@@ -47,6 +48,7 @@ def __init__(self, *, container: "Container", **kwargs) -> None:
4748
"""Initialize a container instance."""
4849
super().__init__(element=container, **kwargs)
4950
self.container = container
51+
self.tags.add(Tags.CONTAINER_INSTANCE)
5052

5153
@property
5254
def container_id(self) -> str:

src/structurizr/model/software_system_instance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
StaticStructureElementInstance,
2626
StaticStructureElementInstanceIO,
2727
)
28+
from .tags import Tags
2829

2930

3031
if TYPE_CHECKING:
@@ -47,6 +48,7 @@ def __init__(self, *, software_system: SoftwareSystem, **kwargs) -> None:
4748
"""Initialize a software system instance."""
4849
super().__init__(element=software_system, **kwargs)
4950
self.software_system = software_system
51+
self.tags.add(Tags.SOFTWARE_SYSTEM_INSTANCE)
5052

5153
@property
5254
def software_system_id(self) -> str:

tests/unit/model/test_container_instance.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from structurizr.model.container_instance import ContainerInstance, ContainerInstanceIO
2020
from structurizr.model.http_health_check import HTTPHealthCheck, HTTPHealthCheckIO
21+
from structurizr.model.tags import Tags
2122

2223

2324
class MockModel:
@@ -73,6 +74,15 @@ def test_container_instance_init(attributes):
7374
assert getattr(instance, attr) == expected
7475

7576

77+
def test_container_instance_tags(model_with_container):
78+
"""Check default tags."""
79+
instance = ContainerInstance(
80+
container=model_with_container.mock_container, instance_id="11"
81+
)
82+
assert Tags.ELEMENT in instance.tags
83+
assert Tags.CONTAINER_INSTANCE in instance.tags
84+
85+
7686
def test_container_instance_hydration_retrieves_container_from_id(model_with_container):
7787
"""Check that the container instance is retrieved from the model on hydration."""
7888
io = ContainerInstanceIO(container_id="19", instance_id=3, environment="Live")

tests/unit/model/test_software_system_instance.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
SoftwareSystemInstance,
2222
SoftwareSystemInstanceIO,
2323
)
24+
from structurizr.model.tags import Tags
2425

2526

2627
class MockModel:
@@ -76,6 +77,15 @@ def test_software_system_instance_init(attributes):
7677
assert getattr(instance, attr) == expected
7778

7879

80+
def test_software_system_instance_tags(model_with_system):
81+
"""Check default tags."""
82+
node = SoftwareSystemInstance(
83+
software_system=model_with_system.mock_system, instance_id="9"
84+
)
85+
assert Tags.ELEMENT in node.tags
86+
assert Tags.SOFTWARE_SYSTEM_INSTANCE in node.tags
87+
88+
7989
def test_software_system_instance_hydration_retrieves_software_system_from_id(
8090
model_with_system,
8191
):

0 commit comments

Comments
 (0)