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

Remove double entries in flatahb output #354

Merged
merged 5 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/kohlrahbi/unfoldedahb/unfoldedahbtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ def _remove_irrelevant_lines(lines: list[AhbLine]) -> list[AhbLine]:
and line_dict["section_name"] is not None
and line_dict["ahb_expression"] is None
) or (is_ahb_line_only_segment_group_header and is_next_ahb_line_empty)
if not is_empty_ahb_line:

is_double_line = (
line_dict["data_element"] is None
and line_dict["name"] == ""
and line_dict["segment_code"] is None
and line_dict["value_pool_entry"] is None
and line_dict["segment_group_key"] is not None
and line_dict["section_name"] is not None
)
if not is_double_line and not is_empty_ahb_line:
reduced_lines.append(line)
return reduced_lines
40 changes: 40 additions & 0 deletions unittests/test_unfolded_ahb_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,46 @@ def test_convert_to_dataframe(self):
[],
id="Empty Line",
),
pytest.param(
[
AhbLine(
guid=None,
section_name="Ansprechpartner",
segment_group_key="SG3",
segment_code=None,
data_element=None,
value_pool_entry=None,
name=None,
ahb_expression="Kann",
index=0,
),
AhbLine(
guid=None,
section_name="Ansprechpartner",
segment_group_key="SG3",
segment_code=None,
data_element=None,
value_pool_entry=None,
name="",
ahb_expression="Kann",
index=0,
),
],
[
AhbLine(
guid=None,
section_name="Ansprechpartner",
segment_group_key="SG3",
segment_code=None,
data_element=None,
value_pool_entry=None,
name=None,
ahb_expression="Kann",
index=0,
),
],
id="Double Line",
),
],
)
def test_remove_irrelevant_lines(self, input_lines, expected_output):
Expand Down