Skip to content

Commit 074b0a2

Browse files
yt-msMidnighter
authored andcommitted
fix: SoftwareSystem not hydrating containers correctly
1 parent 96dd492 commit 074b0a2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/structurizr/model/software_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def hydrate(
132132
model += software_system
133133

134134
for container_io in software_system_io.containers:
135-
Container.hydrate(
135+
software_system += Container.hydrate(
136136
container_io,
137137
software_system=software_system,
138138
model=model,

tests/unit/model/test_software_system.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pytest
2020

2121
from structurizr.model.container import Container
22-
from structurizr.model.software_system import SoftwareSystem
22+
from structurizr.model.software_system import SoftwareSystem, SoftwareSystemIO
2323

2424

2525
class MockModel:
@@ -135,3 +135,18 @@ def test_software_system_get_container_with_name(model_with_system: MockModel):
135135
container = empty_system.add_container(name="Test", description="Description")
136136
assert empty_system.get_container_with_name("Test") is container
137137
assert empty_system.get_container_with_name("FooBar") is None
138+
139+
140+
def test_software_system_serialisation(model_with_system: MockModel):
141+
"""Test systems are deserialised correctly."""
142+
empty_system = model_with_system.empty_system
143+
empty_system.add_container(name="Test", description="Description")
144+
145+
system_io = SoftwareSystemIO.from_orm(empty_system)
146+
147+
new_system = SoftwareSystem.hydrate(system_io, model_with_system)
148+
assert new_system.name == "Sys"
149+
assert len(new_system.containers) == 1
150+
container = next(iter(new_system.containers))
151+
assert container.name == "Test"
152+
assert container.parent is new_system

0 commit comments

Comments
 (0)