Skip to content

Commit

Permalink
Support more value types
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Mar 2, 2023
1 parent 174aa5e commit df89c03
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qgis_deployment_toolbelt/jobs/job_environment_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class JobEnvironmentVariables:
"condition": "in",
},
"value": {
"type": str,
"type": (bool, int, str, list),
"required": False,
"default": None,
"possible_values": None,
Expand Down
26 changes: 23 additions & 3 deletions tests/test_job_environment_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit df89c03

Please sign in to comment.