Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
atdb-ldv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
atdb-ldv
Commits
6cdafa11
Commit
6cdafa11
authored
5 months ago
by
Nico Vermaas
Browse files
Options
Downloads
Patches
Plain Diff
SDC-1663 add input validation
parent
2b9a8ddb
No related branches found
No related tags found
1 merge request
!388
Sdc 1663 inputs validation
Pipeline
#106284
failed
5 months ago
Stage: test
Stage: build
Stage: deploy_to_production
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
atdb/taskdatabase/models.py
+2
-2
2 additions, 2 deletions
atdb/taskdatabase/models.py
atdb/taskdatabase/tests/test_input_validation.py
+54
-15
54 additions, 15 deletions
atdb/taskdatabase/tests/test_input_validation.py
with
56 additions
and
17 deletions
atdb/taskdatabase/models.py
+
2
−
2
View file @
6cdafa11
...
@@ -272,8 +272,8 @@ class Task(models.Model):
...
@@ -272,8 +272,8 @@ class Task(models.Model):
# make sure that every task has an activity (also for backward compatibility)
# make sure that every task has an activity (also for backward compatibility)
associate_task_with_activity
(
self
)
associate_task_with_activity
(
self
)
# when a task comes
in as
DEFINING some validation needs to be done.
# when a task
be
comes DEFINING
or DEFINED
some validation needs to be done.
if
(
self
.
status
!=
State
.
DEFINING
.
value
)
&
(
self
.
new_status
==
State
.
DEFIN
ING
.
value
)
:
if
self
.
new_
status
in
[
State
.
DEFINING
.
value
,
State
.
DEFIN
ED
.
value
]
:
validate_inputs
(
self
)
validate_inputs
(
self
)
# when a task goes to PROCESSED... handle the (potential) aggregation functionality
# when a task goes to PROCESSED... handle the (potential) aggregation functionality
...
...
This diff is collapsed.
Click to expand it.
atdb/taskdatabase/tests/test_input_validation.py
+
54
−
15
View file @
6cdafa11
...
@@ -13,7 +13,7 @@ class TestInputValidation(TestCase):
...
@@ -13,7 +13,7 @@ class TestInputValidation(TestCase):
self
.
workflow
=
Workflow
(
id
=
22
,
workflow_uri
=
"
psrfits_requantisation
"
)
self
.
workflow
=
Workflow
(
id
=
22
,
workflow_uri
=
"
psrfits_requantisation
"
)
self
.
workflow
.
save
()
self
.
workflow
.
save
()
self
.
inputs_
in
=
[
self
.
inputs_
with_duplicate
=
[
{
{
"
size
"
:
100
,
"
size
"
:
100
,
"
surl
"
:
"
srm://srm.grid.sara.nl:8443/pnfs/grid.sara.nl/data/lofar/ops/projects/lc5_020/432340/L432340_SB000_uv.dppp.MS_caf35c3d.tar
"
,
"
surl
"
:
"
srm://srm.grid.sara.nl:8443/pnfs/grid.sara.nl/data/lofar/ops/projects/lc5_020/432340/L432340_SB000_uv.dppp.MS_caf35c3d.tar
"
,
...
@@ -33,16 +33,7 @@ class TestInputValidation(TestCase):
...
@@ -33,16 +33,7 @@ class TestInputValidation(TestCase):
"
location
"
:
"
srm.grid.sara.nl
"
"
location
"
:
"
srm.grid.sara.nl
"
}]
}]
self
.
inputs_validated
=
[
self
.
task
=
Task
.
objects
.
create
(
sas_id
=
'
5432
'
,
status
=
'
defining
'
,
new_status
=
'
defining
'
,
size_to_process
=
100
,
workflow
=
self
.
workflow
,
inputs
=
self
.
inputs_in
)
self
.
task
.
save
()
def
test_validate_inputs
(
self
):
# arrange
expected_size
=
300
expected_inputs
=
[
{
{
"
size
"
:
100
,
"
size
"
:
100
,
"
surl
"
:
"
srm://srm.grid.sara.nl:8443/pnfs/grid.sara.nl/data/lofar/ops/projects/lc5_020/432340/L432340_SB000_uv.dppp.MS_caf35c3d.tar
"
,
"
surl
"
:
"
srm://srm.grid.sara.nl:8443/pnfs/grid.sara.nl/data/lofar/ops/projects/lc5_020/432340/L432340_SB000_uv.dppp.MS_caf35c3d.tar
"
,
...
@@ -56,14 +47,62 @@ class TestInputValidation(TestCase):
...
@@ -56,14 +47,62 @@ class TestInputValidation(TestCase):
"
location
"
:
"
srm.grid.sara.nl
"
"
location
"
:
"
srm.grid.sara.nl
"
}]
}]
self
.
task
=
Task
.
objects
.
create
(
sas_id
=
'
5432
'
,
status
=
'
defining
'
,
new_status
=
'
defining
'
,
size_to_process
=
100
,
workflow
=
self
.
workflow
,
inputs
=
self
.
inputs_with_duplicate
)
self
.
task
.
save
()
def
test_validate_inputs
(
self
):
"""
run the validates_inputs function with a task.inputs that contains a duplicate.
The duplicate should be removed, and the size recalculated
"""
# arrange
expected_size
=
300
expected_inputs
=
self
.
inputs_validated
# act
# act
input_validation
.
validate_inputs
(
self
.
task
)
input_validation
.
validate_inputs
(
self
.
task
)
inputs
=
self
.
task
.
inputs
size
=
self
.
task
.
size_to_process
# assert
# assert
self
.
assertEqual
(
inputs
,
expected_inputs
)
self
.
assertEqual
(
self
.
task
.
inputs
,
expected_inputs
)
self
.
assertEqual
(
s
ize
,
expected_size
)
self
.
assertEqual
(
s
elf
.
task
.
size_to_process
,
expected_size
)
def
test_trigger_on_defined
(
self
):
"""
test that the functionality (also) triggers on
'
defined
'
"""
# arrange
expected_size
=
300
expected_inputs
=
self
.
inputs_validated
# set to 'wrong' inputs containing a duplicate
self
.
task
.
inputs
=
self
.
inputs_with_duplicate
# act
self
.
task
.
new_status
=
"
defined
"
self
.
task
.
save
()
# assert
self
.
assertEqual
(
self
.
task
.
inputs
,
expected_inputs
)
self
.
assertEqual
(
self
.
task
.
size_to_process
,
expected_size
)
def
test_no_trigger_on_staged
(
self
):
"""
test that the functionality does not trigger on other statusses, like
'
staged
'
"""
# arrange
expected_inputs
=
self
.
inputs_with_duplicate
# set to 'wrong' inputs containing a duplicate
self
.
task
.
inputs
=
self
.
inputs_with_duplicate
# act
self
.
task
.
new_status
=
"
staged
"
self
.
task
.
save
()
# assert
self
.
assertEqual
(
self
.
task
.
inputs
,
expected_inputs
)
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