Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
diapotb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Remote Modules
diapotb
Commits
a736899f
Commit
a736899f
authored
3 years ago
by
Gaëlle USSEGLIO
Browse files
Options
Downloads
Patches
Plain Diff
TEST : Add tests for post processing chain
parent
b900aed3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!52
Merge for v1.1.0
,
!50
Finalize Python chains (v1.1.0)
,
!49
Add python tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_src/diapotb/lib/PostProcessing.py
+1
-1
1 addition, 1 deletion
python_src/diapotb/lib/PostProcessing.py
python_src/tests/test_post_precessing_mock.py
+129
-0
129 additions, 0 deletions
python_src/tests/test_post_precessing_mock.py
with
130 additions
and
1 deletion
python_src/diapotb/lib/PostProcessing.py
+
1
−
1
View file @
a736899f
...
@@ -76,7 +76,7 @@ class PostProcessingDefaultValue(DefaultEnum):
...
@@ -76,7 +76,7 @@ class PostProcessingDefaultValue(DefaultEnum):
ML_FILT_RAN
=
(
str
(
PostProcessingParamS1IW
.
ML_FILT_RAN
),
3
)
ML_FILT_RAN
=
(
str
(
PostProcessingParamS1IW
.
ML_FILT_RAN
),
3
)
ML_FILT_GAIN
=
(
str
(
PostProcessingParamS1IW
.
ML_FILT_GAIN
),
str
(
DInSarParamS1IW
.
INTERF_GAIN
))
ML_FILT_GAIN
=
(
str
(
PostProcessingParamS1IW
.
ML_FILT_GAIN
),
str
(
DInSarParamS1IW
.
INTERF_GAIN
))
FILT_ALPHA
=
(
str
(
PostProcessingParamS1IW
.
FILT_ALPHA
),
0.7
)
FILT_ALPHA
=
(
str
(
PostProcessingParamS1IW
.
FILT_ALPHA
),
0.7
)
SPACING_XY
=
(
str
(
PostProcessingParamS1IW
.
FILT_ALPHA
),
0.0001
)
SPACING_XY
=
(
str
(
PostProcessingParamS1IW
.
SPACING_XY
),
0.0001
)
ACTIVATE_ORTHO
=
(
str
(
PostProcessingParamS1IW
.
ACTIVATE_ORTHO
),
"
yes
"
)
ACTIVATE_ORTHO
=
(
str
(
PostProcessingParamS1IW
.
ACTIVATE_ORTHO
),
"
yes
"
)
ACTIVATE_FILTERING
=
(
str
(
PostProcessingParamS1IW
.
ACTIVATE_FILTERING
),
"
yes
"
)
ACTIVATE_FILTERING
=
(
str
(
PostProcessingParamS1IW
.
ACTIVATE_FILTERING
),
"
yes
"
)
...
...
This diff is collapsed.
Click to expand it.
python_src/tests/test_post_precessing_mock.py
0 → 100644
+
129
−
0
View file @
a736899f
import
pytest
from
diapotb.lib.DiapOTBProcessingFactory
import
DiapOTBProcessingFactory
from
diapotb.lib.core.DiapOTBEnums
import
ChainNames
,
ChainModes
,
ScriptNames
,
Satellite
from
diapotb.lib.PostProcessing
import
PostProcessingParamOthers
,
PostProcessingInputKeysOthers
@pytest.fixture
(
scope
=
"
function
"
)
def
prepare_param
(
mode
):
"""
Add keys to param dictionary
"""
param
=
{}
# Common parameters
param
[
str
(
PostProcessingParamOthers
.
INTERF_GAIN
)]
=
0.1
# TODO : Enable ORTHO (mock SetParameterString)
param
[
str
(
PostProcessingParamOthers
.
ACTIVATE_ORTHO
)]
=
"
false
"
# Specific parameters for Others
if
mode
==
ChainModes
.
OTHERS
:
param
[
str
(
PostProcessingParamOthers
.
GRID_STEP_RAN
)]
=
150
param
[
str
(
PostProcessingParamOthers
.
GRID_STEP_AZI
)]
=
150
yield
param
del
param
@pytest.fixture
(
scope
=
"
function
"
)
def
prepare_inputs
(
mode
):
"""
Build a fake input dict for Post-Processing
"""
inputs
=
{}
# Common input
inputs
[
str
(
PostProcessingInputKeysOthers
.
INTERFERO
)]
=
"
interferogram.tiff
"
# Specific intputs for Others (+ TSX)
if
mode
==
ChainModes
.
OTHERS
:
inputs
[
str
(
PostProcessingInputKeysOthers
.
CARTESIAN_ESTIMATION_REFERENCE
)]
=
"
cartmean_reference.tiff
"
inputs
[
str
(
PostProcessingInputKeysOthers
.
COREGISTRATED_SECONDARY
)]
=
"
coregistrated.tiff
"
inputs
[
str
(
PostProcessingInputKeysOthers
.
GRIDS
)]
=
"
deformation_grid.tiff
"
yield
inputs
del
inputs
@pytest.fixture
(
scope
=
"
function
"
)
def
create_post_precessing_chain
(
mode
,
mocker
,
prepare_param
):
"""
Build post-processing chain thanks to our Factory
"""
mocker
.
patch
(
'
diapotb.lib.core.DiapOTBProcessing.os.path.exists
'
,
return_value
=
True
)
chain_factory
=
DiapOTBProcessingFactory
(
mode
=
mode
)
reference_name
=
"
ref_img.tiff
"
reference_dir
=
"
.
"
secondary_name
=
"
sec_img.tiff
"
secondary_dir
=
"
.
"
param
=
prepare_param
output_dir
=
"
.
"
post_processing_chain
=
chain_factory
.
create_processing
(
str
(
ChainNames
.
POST_PROCESSING
),
secondary_image
=
secondary_name
,
secondary_dir
=
secondary_dir
,
reference_image
=
reference_name
,
reference_dir
=
reference_dir
,
param
=
param
,
output_dir
=
output_dir
)
# Return chain
yield
post_processing_chain
del
post_processing_chain
del
chain_factory
#### Base class to mock application execution ######
class
MockApplication
():
"""
Base class to mock OTB applications :
Do not execute applications, just check if all inputs/outputs/param were provided
"""
def
mock_application
(
self
):
print
(
"
Mock Application Execution : Do nothing instead of otbApplication.Application.ExecuteAndWriteOutput
"
)
return
True
def
mock_get_output_image
(
self
,
parameter_name
):
print
(
"
Mock get_output_image : return current name
"
)
return
parameter_name
#### Tests ####
class
TestPostProcessing
(
MockApplication
):
"""
Test PostProcessing chain (only chains not applications)
"""
@pytest.fixture
(
scope
=
"
class
"
,
params
=
[
ChainModes
.
OTHERS
,
ChainModes
.
S1_IW
])
def
mode
(
self
,
request
):
return
request
.
param
def
test_chain
(
self
,
create_post_precessing_chain
,
prepare_inputs
,
mocker
):
mocker
.
patch
(
'
otbApplication.Application.ExecuteAndWriteOutput
'
,
self
.
mock_application
)
mocker
.
patch
(
'
otbApplication.Application.Execute
'
,
self
.
mock_application
)
mocker
.
patch
(
'
diapotb.lib.PostProcessing.OTBApplicationWrapper.get_output_image
'
,
self
.
mock_get_output_image
)
# Get chain
post_precessing_chain
=
create_post_precessing_chain
post_precessing_chain
.
append_inputs
(
prepare_inputs
)
# Execute
post_precessing_chain
.
execute
(
dem_path
=
"
dem.hgt
"
)
# Get outputs
post_precessing_chain
.
get_outputs
()
assert
len
(
post_precessing_chain
.
get_outputs
())
>
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment