From df89c03263fffc119838dddf27378659ef9b6b84 Mon Sep 17 00:00:00 2001 From: Julien M Date: Thu, 2 Mar 2023 14:57:26 +0100 Subject: [PATCH] Support more value types --- .../jobs/job_environment_variables.py | 2 +- tests/test_job_environment_variables.py | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/qgis_deployment_toolbelt/jobs/job_environment_variables.py b/qgis_deployment_toolbelt/jobs/job_environment_variables.py index 5d9dd629..628cc9db 100644 --- a/qgis_deployment_toolbelt/jobs/job_environment_variables.py +++ b/qgis_deployment_toolbelt/jobs/job_environment_variables.py @@ -66,7 +66,7 @@ class JobEnvironmentVariables: "condition": "in", }, "value": { - "type": str, + "type": (bool, int, str, list), "required": False, "default": None, "possible_values": None, diff --git a/tests/test_job_environment_variables.py b/tests/test_job_environment_variables.py index b9d08cde..3b70bade 100644 --- a/tests/test_job_environment_variables.py +++ b/tests/test_job_environment_variables.py @@ -149,8 +149,28 @@ def test_prepare_value(self): def test_validate_options(self): """Test validate_options method""" job_env_vars = JobEnvironmentVariables([]) - # Options must be a list of dictionaries - with self.assertRaises(Exception): + # Options must be a dictionary + with self.assertRaises(ValueError): job_env_vars.validate_options(options="options_test") - with self.assertRaises(Exception): + with self.assertRaises(ValueError): job_env_vars.validate_options(options=["options_test"]) + + bad_options_scope = [ + { + "action": "remove", + "name": "QDT_TEST_FAKE_ENV_VAR_BOOL", + "scope": "imaginary_scope", + } + ] + bad_options_action = [ + { + "action": "update", + "name": "QDT_TEST_FAKE_ENV_VAR_PATH", + "scope": "user", + }, + ] + + with self.assertRaises(ValueError): + JobEnvironmentVariables(bad_options_action) + with self.assertRaises(ValueError): + JobEnvironmentVariables(bad_options_scope)