diff --git a/dev_requirements/requirements-type_check.txt b/dev_requirements/requirements-type_check.txt index 987d5b0..fb917ab 100644 --- a/dev_requirements/requirements-type_check.txt +++ b/dev_requirements/requirements-type_check.txt @@ -5,11 +5,11 @@ # # pip-compile-multi # -mypy==1.10.0 - # via -r dev_requirements\requirements-type_check.in +mypy==1.10.1 + # via -r dev_requirements/requirements-type_check.in mypy-extensions==1.0.0 # via mypy types-xmltodict==0.13.0.3 - # via -r dev_requirements\requirements-type_check.in + # via -r dev_requirements/requirements-type_check.in typing-extensions==4.11.0 # via mypy diff --git a/requirements.txt b/requirements.txt index fbf260e..96ca10d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in @@ -8,6 +8,8 @@ attrs==23.2.0 # via -r requirements.in click==8.1.7 # via -r requirements.in +colorama==0.4.6 + # via click lark==1.1.9 # via -r requirements.in lxml==5.2.2 diff --git a/src/maus/models/anwendungshandbuch.py b/src/maus/models/anwendungshandbuch.py index 5a7a1c5..f349d0d 100644 --- a/src/maus/models/anwendungshandbuch.py +++ b/src/maus/models/anwendungshandbuch.py @@ -83,7 +83,13 @@ class AhbLine: ) """a requirement indicator + an optional condition ("ahb expression"), e.g. 'Muss [123] O [456]' """ # note: to parse expressions from AHBs consider using AHBicht: https://github.com/Hochfrequenz/ahbicht/ - + conditions: Optional[str] = attrs.field( + validator=attrs.validators.optional(validator=attrs.validators.instance_of(str)), default=None + ) + """ + The condition text describes the text to the optional condition of the ahb expression. + E.g. '[492] This is a condition text. [999] And this is another one.' + """ section_name: Optional[str] = attrs.field( validator=attrs.validators.optional(validator=attrs.validators.instance_of(str)), default=None ) @@ -141,6 +147,7 @@ class AhbLineSchema(Schema): value_pool_entry = fields.String(required=False, load_default=None) name = fields.String(required=False, load_default=None) ahb_expression = fields.String(required=False, load_default=None) + conditions = fields.String(required=False, load_default=None) section_name = fields.String(required=False, load_default=None) index = fields.Int(required=False, load_default=None, dump_default=None) diff --git a/tests/unit_tests/test_ahb.py b/tests/unit_tests/test_ahb.py index 3ee7d1c..6a789f5 100644 --- a/tests/unit_tests/test_ahb.py +++ b/tests/unit_tests/test_ahb.py @@ -28,6 +28,7 @@ line_x = AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -37,6 +38,7 @@ ) line_y = AhbLine( ahb_expression="Muss [3] O [4]", + conditions="[3] Test\n[4] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -86,6 +88,7 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", segment_id="01234", @@ -105,12 +108,14 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "Foo", + "conditions": "[1] Test\n[2] Test", "index": None, }, ), pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", segment_id=None, @@ -131,6 +136,7 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "Foo", + "conditions": "[1] Test\n[2] Test", "index": 42, }, ), @@ -156,6 +162,7 @@ def test_ahb_line_equality(self, line_x: AhbLine, line_y: AhbLine, are_equal: bo pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -201,6 +208,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -214,6 +222,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -227,6 +236,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key=None, segment_code="UNH", data_element="0062", @@ -252,6 +262,7 @@ def test_ahbline_get_discriminator(self, ahb_line: AhbLine, include_name: bool, lines=[ AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -280,6 +291,7 @@ def test_ahbline_get_discriminator(self, ahb_line: AhbLine, include_name: bool, "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "MP-ID Absender", + "conditions": "[1] Test\n[2] Test", "index": None, } ],