Skip to content

Commit

Permalink
tests: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Mar 22, 2024
1 parent fa51d7a commit 36983a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
15 changes: 6 additions & 9 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down
17 changes: 8 additions & 9 deletions tests/test_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
import capellambse
import pytest

from capellambse_context_diagrams.collectors import makers


@pytest.mark.parametrize(
"uuid,expected_labels",
[
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",
),
Expand All @@ -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

0 comments on commit 36983a0

Please sign in to comment.