From 36983a05e09ce2dfd11b58881917c965b9b2fa2e Mon Sep 17 00:00:00 2001 From: ewuerger Date: Fri, 22 Mar 2024 15:51:32 +0100 Subject: [PATCH] tests: Fix tests --- tests/test_filters.py | 15 ++++++--------- tests/test_labels.py | 17 ++++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/tests/test_filters.py b/tests/test_filters.py index fb912359..f498aeca 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -68,7 +68,7 @@ def start_filter_apply_test( def get_ExchangeItems(edge: diagram.Edge) -> list[str]: - label = " ".join(edge.labels[0].labels) + label = edge.labels[0].label assert isinstance(label, str) match = EX_PTRN.match(label) assert match is not None @@ -129,8 +129,8 @@ def test_context_diagrams_FEX_EX_ITEMS_is_applied( assert isinstance(aedge, diagram.Edge) assert len(aedge.labels) == 1 - assert isinstance(aedge.labels[0].labels, list) - assert [" ".join(aedge.labels[0].labels)] == [expected_label] + assert isinstance(aedge.labels[0].label, str) + assert [aedge.labels[0].label] == [expected_label] @pytest.mark.parametrize("uuid", (FNC_UUID, INTERF_UUID)) @@ -146,7 +146,7 @@ def test_context_diagrams_FEX_OR_EX_ITEMS_is_applied( assert isinstance(aedge, diagram.Edge) - label = " ".join(aedge.labels[0].labels) + label = aedge.labels[0].label if edge.exchange_items: eitem_label_frag = ", ".join( (exi.name for exi in edge.exchange_items) @@ -177,7 +177,7 @@ def test_context_diagrams_SYSTEM_EX_RELABEL_is_applied( for element in diag.render(None): if isinstance(element, diagram.Edge): - assert element.labels[0].labels[0] in expected + assert element.labels[0].label in expected def test_context_diagrams_NO_UUID_is_applied(model: MelodyModel) -> None: @@ -190,10 +190,7 @@ def test_context_diagrams_NO_UUID_is_applied(model: MelodyModel) -> None: aedge = aird_diag[CAP_EXPLOIT] assert isinstance(aedge, diagram.Edge) - assert ( - " ".join(aedge.labels[0].labels) - == "[CapabilityExploitation] to Capability" - ) + assert aedge.labels[0].label == "[CapabilityExploitation] to Capability" def test_context_diagrams_no_edgelabels_render_param_is_applied( diff --git a/tests/test_labels.py b/tests/test_labels.py index e448c43e..17b26a1b 100644 --- a/tests/test_labels.py +++ b/tests/test_labels.py @@ -4,6 +4,8 @@ import capellambse import pytest +from capellambse_context_diagrams.collectors import makers + @pytest.mark.parametrize( "uuid,expected_labels", @@ -11,13 +13,10 @@ pytest.param( "d817767f-68b7-49a5-aa47-13419d41df0a", [ - "Really long", - "label that", - "needs", - "wrapping else", - "its parent box", - "is also very", - "long!", + "Really long label that", + "needs wrapping else", + "its parent box is also", + "very long!", ], id="LogicalFunction", ), @@ -28,6 +27,6 @@ def test_context_diagrams( ) -> None: obj = model.by_uuid(uuid) - diagram = obj.context_diagram.render(None) + labels = makers.make_label(obj.name, max_width=makers.MAX_LABEL_WIDTH) - assert diagram[uuid].labels[0].labels == expected_labels + assert [label["text"] for label in labels] == expected_labels