Skip to content

Commit

Permalink
Remove double entries in flatahb output (#354)
Browse files Browse the repository at this point in the history
* remove irrelevant lines in flatahb output

* remove double lines in flatahb output

* modified test
  • Loading branch information
DeltaDaniel committed Jul 10, 2024
1 parent 22e5673 commit eeeb3b2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
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

0 comments on commit eeeb3b2

Please sign in to comment.