Skip to content

Commit

Permalink
feat: Add Physical Links for Context Diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed May 22, 2024
1 parent 7972e0b commit 90099cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 0 additions & 2 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,13 @@ def register_classes() -> None:
DiagramType.PAB,
{
"display_parent_relation": True,
"render_styles": styling.BLUE_ACTOR_FNCS,
},
),
(
pa.PhysicalFunction,
DiagramType.PAB,
{
"display_parent_relation": True,
"render_styles": styling.BLUE_ACTOR_FNCS,
},
),
]
Expand Down
10 changes: 8 additions & 2 deletions capellambse_context_diagrams/collectors/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,14 @@ def port_exchange_collector(
edges: dict[str, common.ElementList[fa.AbstractExchange]] = {}
for i in ports:
try:
if edge := filter(getattr(i, "exchanges")):
edges[i.uuid] = edge
if exs := filter(getattr(i, "exchanges")):
edges[i.uuid] = exs
continue
except AttributeError:
pass
try:
if links := filter(getattr(i, "links")):
edges[i.uuid] = links
except AttributeError:
pass
return edges
Expand Down
24 changes: 19 additions & 5 deletions tests/test_context_diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"f0bc11ba-89aa-4297-98d2-076440e9117f",
}
TEST_DERIVED_UUID = "dbd99773-efb6-4476-bf5c-270a61f18b09"
TEST_PHYSICAL_UUID = "fdb34c92-7c49-491d-bf11-dd139930786e"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -187,9 +186,24 @@ def test_context_diagram_with_derived_interfaces(
assert len(derived_diagram) > 5


def test_context_diagram_of_physical_component(
model: capellambse.MelodyModel,
@pytest.mark.parametrize(
"uuid",
[
pytest.param(
"fdb34c92-7c49-491d-bf11-dd139930786e", id="PhysicalNodeComponent"
),
pytest.param(
"313f48f4-fb7e-47a8-b28a-76440932fcb9",
id="PhysicalBehaviorComponent",
),
],
)
def test_context_diagram_of_physical_node_component(
model: capellambse.MelodyModel, uuid: str
) -> None:
obj = model.by_uuid(TEST_PHYSICAL_UUID)
obj = model.by_uuid(uuid)

diag = obj.context_diagram
diag.render("svgdiagram").save(pretty=True)

diag = obj.context_diagram.render("svgdiagram").save(pretty=True)
assert len(diag.nodes) > 1

0 comments on commit 90099cc

Please sign in to comment.