diff --git a/alfalfa_worker/lib/utils.py b/alfalfa_worker/lib/utils.py index 82c5f492..e20f5553 100644 --- a/alfalfa_worker/lib/utils.py +++ b/alfalfa_worker/lib/utils.py @@ -24,9 +24,11 @@ def to_bool(value: str): true_strings = ["true", "yes", "1"] if isinstance(value, bool): return value - elif value.lower() in false_strings: + if value is None: return False - elif value.lower() in true_strings: - return True - else: - raise ValueError(f"Invalid string \"{value}\" provided for boolean conversion") + if isinstance(value, str): + if value.lower() in false_strings: + return False + elif value.lower() in true_strings: + return True + raise ValueError(f"Invalid string \"{value}\" provided for boolean conversion") diff --git a/tests/worker/test_job_step_run.py b/tests/worker/test_job_step_run.py index 29999a6a..9ce8b1e1 100644 --- a/tests/worker/test_job_step_run.py +++ b/tests/worker/test_job_step_run.py @@ -26,7 +26,7 @@ def step_run_mock_job(dispatcher: Dispatcher): "start_datetime": str(datetime(2019, 1, 2, 0, 0, 0)), "end_datetime": str(datetime(2019, 1, 3, 0, 0, 0)), "timescale": "20", - "realtime": None + "realtime": False } yield dispatcher.create_job(StepRunMockJob.job_path(), params)