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

fix: parameter value default is never required #1419

Merged
merged 1 commit into from
Jul 5, 2023
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
2 changes: 1 addition & 1 deletion tests/trestle/tasks/csv_to_oscal_cd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def test_execute_missing_param_default_value(tmp_path: pathlib.Path) -> None:
mock_csv_reader.return_value = rows
tgt = csv_to_oscal_cd.CsvToOscalComponentDefinition(section)
retval = tgt.execute()
assert retval == TaskOutcome.FAILURE
assert retval == TaskOutcome.SUCCESS


def test_execute_change_param_default_value(tmp_path: pathlib.Path) -> None:
Expand Down
13 changes: 7 additions & 6 deletions trestle/tasks/csv_to_oscal_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,19 @@ def _create_set_parameter(self, rule_key: tuple) -> SetParameter:
"""Create create set parameters."""
set_parameter = None
name = self._csv_mgr.get_value(rule_key, PARAMETER_ID)
if name:
value = self._csv_mgr.get_value(rule_key, PARAMETER_VALUE_DEFAULT)
if name and value:
value = self._csv_mgr.get_value(rule_key, PARAMETER_VALUE_DEFAULT)
if value == '':
row_number = self._csv_mgr.get_row_number(rule_key)
column_name = PARAMETER_VALUE_DEFAULT
text = f'row "{row_number}" missing value for "{column_name}"'
raise RuntimeError(text)
values = value.split(',')
set_parameter = SetParameter(
param_id=name,
values=values,
)
elif name:
row_number = self._csv_mgr.get_row_number(rule_key)
column_name = PARAMETER_VALUE_DEFAULT
text = f'row "{row_number}" missing value for "{column_name}"'
logger.debug(text)
return set_parameter

def _get_implemented_requirement(
Expand Down