Skip to content

Commit

Permalink
test: Fix test with requirements field
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Oct 26, 2023
1 parent fcf080f commit 60b237e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions capella2polarion/elements/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def _get_requirement_types_text(
continue

if not (req.type and req.text):
logger.warning(
"Requirement without text or type found %r", req.name
)
continue

type_texts[req.type.long_name].append(req.text)
Expand Down
37 changes: 28 additions & 9 deletions tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
TEST_WI_CHECKSUM = (
"73508ec0c3048c5b33316dfa56ef5e5f4179ff69efaa209e47ab65b111415e82"
)
TEST_REQ_TEXT = (
"<p>Test requirement 1 really l o n g text that is&nbsp;way too long to "
"display here as that</p>\n\n<p>&lt; &gt; &quot; &#39;</p>\n\n<ul>\n\t<li>"
"This&nbsp;is a list</li>\n\t<li>an unordered one</li>\n</ul>\n\n<ol>\n\t"
"<li>Ordered list</li>\n\t<li>Ok</li>\n</ol>\n"
)


class TestDiagramElements:
Expand Down Expand Up @@ -478,17 +484,22 @@ def test__decode_diagram():
@pytest.mark.parametrize(
"uuid,expected",
[
(
pytest.param(
TEST_ELEMENT_UUID,
{
"type": "logicalComponent",
"title": "Hogwarts",
"uuid_capella": TEST_ELEMENT_UUID,
"description_type": "text/html",
"description": markupsafe.Markup(TEST_DESCR),
"reqtype": {
"type": "text/html",
"value": markupsafe.Markup(TEST_REQ_TEXT),
},
},
id="logicalComponent",
),
(
pytest.param(
TEST_OCAP_UUID,
{
"type": "operationalCapability",
Expand All @@ -501,8 +512,9 @@ def test__decode_diagram():
"postCondition": {"type": "text/html", "value": ""},
},
},
id="operationalCapability",
),
(
pytest.param(
TEST_WE_UUID,
{
"type": "entity",
Expand All @@ -511,8 +523,9 @@ def test__decode_diagram():
"description_type": "text/html",
"description": markupsafe.Markup(TEST_WE_DESCR),
},
id="entity",
),
(
pytest.param(
TEST_ACTOR_UUID,
{
"type": "logicalActor",
Expand All @@ -524,8 +537,9 @@ def test__decode_diagram():
"and greatest mage of all time.</p>\n"
),
},
id="logicalActor",
),
(
pytest.param(
TEST_PHYS_COMP,
{
"type": "physicalComponent",
Expand All @@ -534,8 +548,9 @@ def test__decode_diagram():
"description_type": "text/html",
"description": markupsafe.Markup(""),
},
id="physicalComponent",
),
(
pytest.param(
TEST_PHYS_NODE,
{
"type": "physicalComponentNode",
Expand All @@ -544,8 +559,9 @@ def test__decode_diagram():
"description_type": "text/html",
"description": markupsafe.Markup(""),
},
id="physicalComponentNode",
),
(
pytest.param(
TEST_SCENARIO,
{
"type": "scenario",
Expand All @@ -558,8 +574,9 @@ def test__decode_diagram():
"postCondition": {"type": "text/html", "value": ""},
},
},
id="scenario",
),
(
pytest.param(
TEST_CAP_REAL,
{
"type": "capabilityRealization",
Expand All @@ -572,8 +589,9 @@ def test__decode_diagram():
"postCondition": {"type": "text/html", "value": ""},
},
},
id="capabilityRealization",
),
(
pytest.param(
TEST_CONSTRAINT,
{
"type": "constraint",
Expand All @@ -584,6 +602,7 @@ def test__decode_diagram():
"This is a test context.Make Food"
),
},
id="constraint",
),
],
)
Expand Down

0 comments on commit 60b237e

Please sign in to comment.