Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compare all AHB props to handle row insertion at arb. positions #37

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

OLILHR
Copy link
Member

@OLILHR OLILHR commented Dec 1, 2024

Screenshot 2024-12-05 at 16 13 30

fixes row insertion at arb. positions to prevent "unnecessary" MODIFIED flags.

got test_align_rows_all_ahb_properties_within_section_name to work while keeping the comparison logic compatible with the remaining tests.

    def test_align_rows_all_ahb_properties_within_section_name(self) -> None:
        # to handle rows that have been inserted at arbitrary positions within the same `section_name` group
        # for example FV2504 UTILMD 55078 (SG3 Ansprechpartner):
        # `previous_ahb_rows` should add an empty row at the top (NEW) for AhbRow's to align properly
        previous_ahb_rows = [
            AhbRow(  # equivalent to second AhbRow of `subsequent_ahb_rows`
                formatversion=self.formatversions.previous_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element=None,
                segment_id="00009",
                value_pool_entry=None,
                name=None,
                ahb_expression="Muss",
                conditions=None,
            ),
            AhbRow(
                formatversion=self.formatversions.previous_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element="3139",
                segment_id="00009",
                value_pool_entry="IC",
                name="Informationskontakt",
                ahb_expression="X",
                conditions=None,
            ),
            AhbRow(
                formatversion=self.formatversions.previous_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element="3412",
                segment_id="00009",
                value_pool_entry=None,
                name="Name vom Ansprechpartner",
                ahb_expression="X",
                conditions=None,
            ),
        ]
        subsequent_ahb_rows = [
            AhbRow(  # NEW
                formatversion=self.formatversions.subsequent_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code=None,
                data_element=None,
                segment_id=None,
                value_pool_entry=None,
                name=None,
                ahb_expression="Kann",
                conditions=None,
            ),
            AhbRow(  # equivalent to first AhbRow of `previous_ahb_rows`
                formatversion=self.formatversions.subsequent_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element=None,
                segment_id="00009",
                value_pool_entry=None,
                name=None,
                ahb_expression="Muss",
                conditions=None,
            ),
            AhbRow(
                formatversion=self.formatversions.subsequent_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element="3139",
                segment_id="00009",
                value_pool_entry="IC",
                name="Informationskontakt",
                ahb_expression="X",
                conditions=None,
            ),
            AhbRow(
                formatversion=self.formatversions.subsequent_formatversion,
                section_name="Ansprechpartner",
                segment_group_key="SG3",
                segment_code="CTA",
                data_element="3412",
                segment_id="00009",
                value_pool_entry=None,
                name="Name vom Ansprechpartner",
                ahb_expression="X",
                conditions=None,
            ),
        ]

        result = align_ahb_rows(previous_ahb_rows, subsequent_ahb_rows)

        assert len(result) == 4
        assert result[0].diff.diff_type == DiffType.ADDED
        assert result[1].diff.diff_type == DiffType.UNCHANGED
        assert result[2].diff.diff_type == DiffType.UNCHANGED
        assert result[3].diff.diff_type == DiffType.UNCHANGED

        assert not result[1].diff.changed_entries
        assert not result[2].diff.changed_entries
        assert not result[3].diff.changed_entries

@OLILHR OLILHR linked an issue Dec 1, 2024 that may be closed by this pull request
@OLILHR OLILHR requested a review from a team December 5, 2024 15:24
@OLILHR OLILHR marked this pull request as ready for review December 5, 2024 15:24
@OLILHR OLILHR mentioned this pull request Dec 5, 2024
4 tasks
Copy link

@hf-krechan hf-krechan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :)
will das für AHB Tabellen haben ;)

@OLILHR OLILHR merged commit f7f1828 into main Dec 5, 2024
19 checks passed
@OLILHR OLILHR deleted the feat/compare-all-props branch December 5, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check all AHB properties within the same segment during row alignment
2 participants