|
1 | 1 | from reqif.parser import ReqIFParser |
2 | 2 |
|
3 | 3 |
|
4 | | -def test_01_indenting_unintended_xhtml(): |
| 4 | +def test_01_normal_case(): |
5 | 5 | input_reqif = """\ |
6 | 6 | <?xml version="1.0" encoding="UTF-8"?> |
7 | 7 | <REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xmlns:configuration="http://eclipse.org/rmf/pror/toolextensions/1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
@@ -48,3 +48,101 @@ def test_01_indenting_unintended_xhtml(): |
48 | 48 | ].value_stripped_xhtml |
49 | 49 | == expected_stripped_xhtml |
50 | 50 | ) |
| 51 | + |
| 52 | + |
| 53 | +def test_02_edge_case_object_tag_no_xhtml_ns(): |
| 54 | + input_reqif = """\ |
| 55 | +<?xml version="1.0" encoding="UTF-8"?> |
| 56 | +<REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xmlns:configuration="http://eclipse.org/rmf/pror/toolextensions/1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
| 57 | + <CORE-CONTENT> |
| 58 | + <REQ-IF-CONTENT> |
| 59 | + <SPEC-OBJECTS> |
| 60 | + <SPEC-OBJECT IDENTIFIER="TEST_SPEC_OBJECT_IDENTIFIER" LAST-CHANGE="2021-10-15T11:34:36.007+02:00"> |
| 61 | + <VALUES> |
| 62 | + <ATTRIBUTE-VALUE-XHTML> |
| 63 | + <DEFINITION> |
| 64 | + <ATTRIBUTE-DEFINITION-XHTML-REF>_gFhrXWojEeuExICsU7Acmg</ATTRIBUTE-DEFINITION-XHTML-REF> |
| 65 | + </DEFINITION> |
| 66 | + <THE-VALUE> |
| 67 | + <xhtml:div> |
| 68 | + <object data="files/rmf-1b18ef37-ca1f-4e79-954d-747df083f861_DOCATTACHMENT_3-screenshot-20220926-051927.png" name="DOCATTACHMENT_3-screenshot-20220926-051927.png" type="image/png"/> |
| 69 | + </xhtml:div> |
| 70 | + </THE-VALUE> |
| 71 | + </ATTRIBUTE-VALUE-XHTML> |
| 72 | + </VALUES> |
| 73 | + <TYPE> |
| 74 | + <SPEC-OBJECT-TYPE-REF>TEST_SPEC_OBJECT_TYPE_IDENTIFIER_FUNCTIONAL</SPEC-OBJECT-TYPE-REF> |
| 75 | + </TYPE> |
| 76 | + </SPEC-OBJECT> |
| 77 | + </SPEC-OBJECTS> |
| 78 | + </REQ-IF-CONTENT> |
| 79 | + </CORE-CONTENT> |
| 80 | +</REQ-IF> |
| 81 | +""" # noqa: E501 |
| 82 | + |
| 83 | + expected_stripped_xhtml = """\ |
| 84 | +<div> |
| 85 | + <object data="files/rmf-1b18ef37-ca1f-4e79-954d-747df083f861_DOCATTACHMENT_3-screenshot-20220926-051927.png" name="DOCATTACHMENT_3-screenshot-20220926-051927.png" type="image/png"></object> |
| 86 | +</div>\ |
| 87 | +""" # noqa: E501 |
| 88 | + |
| 89 | + reqif_bundle = ReqIFParser.parse_from_string(input_reqif) |
| 90 | + spec_object = reqif_bundle.get_spec_object_by_ref( |
| 91 | + "TEST_SPEC_OBJECT_IDENTIFIER" |
| 92 | + ) |
| 93 | + |
| 94 | + assert ( |
| 95 | + spec_object.attribute_map[ |
| 96 | + "_gFhrXWojEeuExICsU7Acmg" |
| 97 | + ].value_stripped_xhtml |
| 98 | + == expected_stripped_xhtml |
| 99 | + ) |
| 100 | + |
| 101 | + |
| 102 | +def test_03_edge_case_object_tag_xhtml_ns(): |
| 103 | + input_reqif = """\ |
| 104 | +<?xml version="1.0" encoding="UTF-8"?> |
| 105 | +<REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xmlns:configuration="http://eclipse.org/rmf/pror/toolextensions/1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
| 106 | + <CORE-CONTENT> |
| 107 | + <REQ-IF-CONTENT> |
| 108 | + <SPEC-OBJECTS> |
| 109 | + <SPEC-OBJECT IDENTIFIER="TEST_SPEC_OBJECT_IDENTIFIER" LAST-CHANGE="2021-10-15T11:34:36.007+02:00"> |
| 110 | + <VALUES> |
| 111 | + <ATTRIBUTE-VALUE-XHTML> |
| 112 | + <DEFINITION> |
| 113 | + <ATTRIBUTE-DEFINITION-XHTML-REF>_gFhrXWojEeuExICsU7Acmg</ATTRIBUTE-DEFINITION-XHTML-REF> |
| 114 | + </DEFINITION> |
| 115 | + <THE-VALUE> |
| 116 | + <xhtml:div> |
| 117 | + <xhtml:object data="files/rmf-1b18ef37-ca1f-4e79-954d-747df083f861_DOCATTACHMENT_3-screenshot-20220926-051927.png" name="DOCATTACHMENT_3-screenshot-20220926-051927.png" type="image/png"/> |
| 118 | + </xhtml:div> |
| 119 | + </THE-VALUE> |
| 120 | + </ATTRIBUTE-VALUE-XHTML> |
| 121 | + </VALUES> |
| 122 | + <TYPE> |
| 123 | + <SPEC-OBJECT-TYPE-REF>TEST_SPEC_OBJECT_TYPE_IDENTIFIER_FUNCTIONAL</SPEC-OBJECT-TYPE-REF> |
| 124 | + </TYPE> |
| 125 | + </SPEC-OBJECT> |
| 126 | + </SPEC-OBJECTS> |
| 127 | + </REQ-IF-CONTENT> |
| 128 | + </CORE-CONTENT> |
| 129 | +</REQ-IF> |
| 130 | +""" # noqa: E501 |
| 131 | + |
| 132 | + expected_stripped_xhtml = """\ |
| 133 | +<div> |
| 134 | + <object data="files/rmf-1b18ef37-ca1f-4e79-954d-747df083f861_DOCATTACHMENT_3-screenshot-20220926-051927.png" name="DOCATTACHMENT_3-screenshot-20220926-051927.png" type="image/png"></object> |
| 135 | +</div>\ |
| 136 | +""" # noqa: E501 |
| 137 | + |
| 138 | + reqif_bundle = ReqIFParser.parse_from_string(input_reqif) |
| 139 | + spec_object = reqif_bundle.get_spec_object_by_ref( |
| 140 | + "TEST_SPEC_OBJECT_IDENTIFIER" |
| 141 | + ) |
| 142 | + |
| 143 | + assert ( |
| 144 | + spec_object.attribute_map[ |
| 145 | + "_gFhrXWojEeuExICsU7Acmg" |
| 146 | + ].value_stripped_xhtml |
| 147 | + == expected_stripped_xhtml |
| 148 | + ) |
0 commit comments