From 1e24b1a1273e1c157e37fcdc82cb4bf941a366dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Thu, 9 Jan 2020 16:15:36 +0100 Subject: [PATCH] Fix default UPDATE_KEYS with threshold in CALCULATE_KEYS --- .../job_config.py | 4 +++- .../unit/test_scaling_job.py | 23 ++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/semeio/jobs/correlated_observations_scaling/job_config.py b/semeio/jobs/correlated_observations_scaling/job_config.py index 3a686aca0..394791e39 100644 --- a/semeio/jobs/correlated_observations_scaling/job_config.py +++ b/semeio/jobs/correlated_observations_scaling/job_config.py @@ -72,7 +72,9 @@ def _realize_list(input_string): def _expand_input(input_value): expanded_values = deepcopy(input_value) if "CALCULATE_KEYS" in expanded_values and "UPDATE_KEYS" not in expanded_values: - expanded_values.update({"UPDATE_KEYS": expanded_values["CALCULATE_KEYS"]}) + expanded_values.update( + {"UPDATE_KEYS": {"keys": expanded_values["CALCULATE_KEYS"]["keys"]}} + ) return expanded_values diff --git a/tests/jobs/correlated_observations_scaling/unit/test_scaling_job.py b/tests/jobs/correlated_observations_scaling/unit/test_scaling_job.py index 1e38983d5..34cde0566 100644 --- a/tests/jobs/correlated_observations_scaling/unit/test_scaling_job.py +++ b/tests/jobs/correlated_observations_scaling/unit/test_scaling_job.py @@ -89,30 +89,27 @@ def test_min_value(test_input, expected_result): assert job_config._min_value(test_input).__bool__() == expected_result -def test_expand_input(): +def test_expand_input_no_modification(): expected_result = { "UPDATE_KEYS": {"keys": [{"key": "key_4"}, {"key": "key_5"}, {"key": "key_6"}]}, "CALCULATE_KEYS": { - "keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}] + "keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}], + "threshold": 1.0, }, } - valid_config = deepcopy(expected_result) - assert job_config._expand_input(deepcopy(expected_result)) == expected_result - copy_of_valid_config = deepcopy(valid_config) - copy_of_valid_config.pop("UPDATE_KEYS") - expected_result = { - "UPDATE_KEYS": {"keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}]}, - "CALCULATE_KEYS": { - "keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}] - }, - } +def test_expand_input_modification(): + keys = [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}] + test_input = {"CALCULATE_KEYS": {"keys": keys, "threshold": 1.0}} + + expected_results = deepcopy(test_input) + expected_results["UPDATE_KEYS"] = {"keys": keys} - assert job_config._expand_input(copy_of_valid_config) == expected_result + assert job_config._expand_input(test_input) == expected_results def test_config_setup():