From 3cf9088a8914374d156f32079f7303664963750f Mon Sep 17 00:00:00 2001 From: huyenngn Date: Wed, 22 Jan 2025 09:22:13 +0000 Subject: [PATCH] test: Add blackbox test --- .../collectors/default.py | 7 +- src/capellambse_context_diagrams/context.py | 7 +- tests/data/ContextDiagram.aird | 415 ++++++++++++++++++ tests/data/ContextDiagram.capella | 71 +++ tests/test_context_diagrams.py | 24 +- 5 files changed, 501 insertions(+), 23 deletions(-) diff --git a/src/capellambse_context_diagrams/collectors/default.py b/src/capellambse_context_diagrams/collectors/default.py index 0f0992bb..266be17e 100644 --- a/src/capellambse_context_diagrams/collectors/default.py +++ b/src/capellambse_context_diagrams/collectors/default.py @@ -61,6 +61,8 @@ def _collect_extended_context( target: m.ModelElement, ) -> cabc.Iterator[m.ModelElement]: yield from _collect(target) + if not diagram._display_actor_relation: + return oc_copy = outside_components.copy() for cmp in oc_copy.values(): yield from _collect( @@ -73,10 +75,7 @@ def _collect_extended_context( ), ) - if diagram._display_actor_relationship: - diagram._collect = _collect(diagram.target) - else: - diagram._collect = _collect_extended_context(diagram.target) + diagram._collect = _collect_extended_context(diagram.target) processor = custom.CustomCollector(diagram, params=params) processor() return processor.data diff --git a/src/capellambse_context_diagrams/context.py b/src/capellambse_context_diagrams/context.py index 853ae564..9794bfdb 100644 --- a/src/capellambse_context_diagrams/context.py +++ b/src/capellambse_context_diagrams/context.py @@ -288,7 +288,7 @@ class CustomDiagram(m.AbstractDiagram): * collect - A list of collected elements. * unify_edge_direction - Unify the direction of the edges. * balckbox - Display the object of interest as a black box. - * display_actor_relationship: Show the connections between the context actors. + * display_actor_relation: Show the connections between the context actors. """ _display_symbols_as_boxes: bool @@ -302,7 +302,7 @@ class CustomDiagram(m.AbstractDiagram): _collect: cabc.Iterator[m.ModelElement] _unify_edge_direction: str _blackbox: bool - _display_actor_relationship: bool + _display_actor_relation: bool def __init__( self, @@ -333,7 +333,7 @@ def __init__( "collect": [], "unify_edge_direction": "NONE", "blackbox": False, - "display_actor_relationship": False, + "display_actor_relation": False, } | default_render_parameters if standard_filter := STANDARD_FILTERS.get(class_): @@ -464,7 +464,6 @@ def __init__( default_render_parameters = { "slim_center_box": True, "unify_edge_direction": "SMART", - "blackbox": True, } | default_render_parameters super().__init__( diff --git a/tests/data/ContextDiagram.aird b/tests/data/ContextDiagram.aird index a320b219..ed0d1a45 100644 --- a/tests/data/ContextDiagram.aird +++ b/tests/data/ContextDiagram.aird @@ -202,6 +202,14 @@ + + +
+
+ + + + @@ -18215,4 +18223,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/ContextDiagram.capella b/tests/data/ContextDiagram.capella index fc551e24..9e3a267b 100644 --- a/tests/data/ContextDiagram.capella +++ b/tests/data/ContextDiagram.capella @@ -3729,6 +3729,17 @@ The predator is far away + + + name="Parent" abstractType="#eb966300-e6a2-40b4-ab9c-98fa1d6d04ad"/> + + + @@ -4513,6 +4530,60 @@ The predator is far away id="36fb9559-675b-4efd-87fd-b20aa893cd44" name="CP 1" orientation="IN" kind="FLOW"/> + + + + + + + + + + + + + + + + + + + + + + + + + + None: - obj = model.by_uuid("77b3349c-9184-478a-b005-893a4d789b47") + obj = model.by_uuid("fd69347c-fca9-4cdd-ae44-9182e13c8d9d") hidden_element_uuids = { - "22881485-4989-49c0-8068-5af004d1db63", - "138c1c84-713d-4567-9304-30364330b5a9", - "386f8111-bd45-4bd0-a22b-b8f6c4b1216a", - "f9897b61-602d-4c18-a72d-f4521e7c094f", - "25f152df-7309-46d1-88ea-b34772c3eb34", - "a662d5a2-beb0-469b-b947-f663ecf8f482", - "47cc117b-3760-470b-9474-0472d149d194", + "9f92e453-0692-4842-9e0c-4d36ab541acd", + "847991cf-546d-4817-b52f-a58b5a42d0e5", + "955b6e5d-df64-4805-8973-93756a4be879", + "ce221886-adfd-45f5-99cf-07baac99458d", } white = obj.context_diagram.render(None, blackbox=False) - black = obj.context_diagram.render("svgdiagram", blackbox=True).save( - pretty=True - ) + black = obj.context_diagram.render(None, blackbox=True) assert {element.uuid for element in white} & hidden_element_uuids assert not {element.uuid for element in black} & hidden_element_uuids