Commit 30cfa0cc authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added validation test for JobConfig.to_dict().

parent 96d668aa
Pipeline #1617 failed with stage
in 10 minutes and 43 seconds
......@@ -321,8 +321,8 @@ class JobConfig(object):
[target_gsd_tmp]*2 if isinstance(target_gsd_tmp, (int, float)) else target_gsd_tmp
self.target_epsg_code = VSSpecs['projection_epsg']
# FIXME values in case user defines only Landsat?
self.spatial_ref_gridx = np.arange(xgsd / 2., xgsd / 2. + 2 * xgsd, xgsd) # e.g. [15, 45]
self.spatial_ref_gridy = np.arange(ygsd / 2., ygsd / 2. + 2 * ygsd, ygsd)
self.spatial_ref_gridx = np.arange(xgsd / 2., xgsd / 2. + 2 * xgsd, xgsd).tolist() # e.g. [15, 45]
self.spatial_ref_gridy = np.arange(ygsd / 2., ygsd / 2. + 2 * ygsd, ygsd).tolist()
#############
# data list #
......@@ -368,11 +368,11 @@ class JobConfig(object):
return getattr(self.DB_job_record, attr_db_job_record)
# 3. JSON parameters: parameters that have been defined via JSON Input (command line or advanced UI params)
if val_json:
if val_json is not None:
return val_json
# fallback: if nothing has been returned until here
if not fallback and key_user_opts in self.kwargs_defaults:
if fallback is None and key_user_opts in self.kwargs_defaults:
fallback = self.kwargs_defaults[key_user_opts]
return fallback
......
......@@ -98,7 +98,7 @@ gms_schema = dict(
type='dict', required=True, schema=dict(
virtual_sensor_id=dict(type='integer', required=True), # TODO add possible values
datasetid_spatial_ref=dict(type='integer', required=True, nullable=True),
datasetid_spectral_ref=dict(type='integer', required=True),
datasetid_spectral_ref=dict(type='integer', required=True, nullable=True),
target_CWL=dict(type='list', required=False, schema=dict(type='float')),
target_FWHM=dict(type='list', required=False, schema=dict(type='float')),
target_gsd=dict(type='list', required=False, schema=dict(type='float'), maxlength=2),
......
......@@ -15,6 +15,8 @@ from json import JSONDecodeError, dumps
from gms_preprocessing.options.config import get_options
from gms_preprocessing.options.config import JobConfig
from gms_preprocessing.options.config import path_options_default
from gms_preprocessing.options.config import GMSValidator
from gms_preprocessing.options.options_schema import gms_schema
class Test_get_options(TestCase):
......@@ -73,3 +75,11 @@ class Test_JobConfig(TestCase):
# test if dict is jsonable
dumps(jsonable_dict)
def test_to_dict_validity(self):
cfg = JobConfig(self.jobID, self.db_host)
params = cfg.to_dict()
self.assertIsInstance(cfg.to_jsonable_dict(), dict)
# check validity
GMSValidator(allow_unknown=True, schema=gms_schema).validate(params)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment