Skip to content

Commit

Permalink
simplify & improve test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Lou DeGenaro <[email protected]>
  • Loading branch information
degenaro committed Jan 3, 2025
1 parent c3a4889 commit a888d68
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/trestle/tasks/cis_xlsx_to_oscal_cd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def test_cis_xlsx_to_oscal_cd_execute_bad_overwrite(tmp_path: pathlib.Path):
assert retval == TaskOutcome.FAILURE


def test_cis_xlsx_to_oscal_cd_execute_merge(tmp_path: pathlib.Path):
"""Test execute call - merge."""
section = _get_section(tmp_path, db2_config)
section['benchmark-file'
] = 'tests/data/tasks/cis-xlsx-to-oscal-cd/CIS_IBM_Db2_11_Benchmark_v1.1.0.snippet_merge.xlsx'
tgt = cis_xlsx_to_oscal_cd.CisXlsxToOscalCd(section)
retval = tgt.execute()
assert retval == TaskOutcome.SUCCESS
_validate_db2(tmp_path)


def _validate_db2(tmp_path: pathlib.Path):
"""Validate produced OSCAL for db2 cd."""
# read catalog
Expand Down
9 changes: 3 additions & 6 deletions trestle/tasks/cis_xlsx_to_oscal_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,15 +804,12 @@ def heading_row_2(self) -> None:

def _get_ctl_list(self, prev_row: int, curr_row: int) -> List[str]:
"""Get_ctl_list."""
ctl_list = []
# if merged row, list is empty
if self.merge_row(prev_row, curr_row):
ctl_list = []
else:
if not self.merge_row(prev_row, curr_row):
# if non-rule row, list is empty
rec_no = self.get(curr_row, head_recommendation_no)
if rec_no is None:
ctl_list = []
else:
if rec_no is not None:
# get list
cis_controls = self.get(curr_row, 'CIS Controls')
cis_control_helper = CisControlsHelper(cis_controls)
Expand Down

0 comments on commit a888d68

Please sign in to comment.