Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
geomultisens
gms_preprocessing
Commits
731cc17f
Commit
731cc17f
authored
Nov 28, 2017
by
Daniel Scheffler
Browse files
Added validation test for JobConfig.to_dict().
Former-commit-id:
30cfa0cc
Former-commit-id:
47bd7f90
parent
ec2104cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
gms_preprocessing/options/config.py
View file @
731cc17f
...
...
@@ -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
...
...
gms_preprocessing/options/options_schema.py
View file @
731cc17f
...
...
@@ -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
),
...
...
tests/test_config.py
View file @
731cc17f
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment