Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LDV Specification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
LDV Specification
Commits
62451b49
Commit
62451b49
authored
1 year ago
by
Klaas Kliffen
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for all field propagation methods
parent
1f4176c4
No related branches found
Branches containing commit
No related tags found
1 merge request
!104
Propagate extra fields form group into WorkSpecifications
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ldvspec/lofardata/tests/test_group_propagation.py
+193
-20
193 additions, 20 deletions
ldvspec/lofardata/tests/test_group_propagation.py
with
193 additions
and
20 deletions
ldvspec/lofardata/tests/test_group_propagation.py
+
193
−
20
View file @
62451b49
...
...
@@ -2,17 +2,19 @@
from
unittest
import
mock
from
rest_framework.status
import
HTTP_302_FOUND
from
django.urls
import
reverse
from
django
import
test
as
dtest
from
django.contrib.auth.models
import
User
from
django.urls
import
reverse
from
lofardata.models
import
ATDBProcessingSite
,
Group
,
WorkSpecification
from
lofardata.tests.util
import
mocked_delay
from
lofardata.view_helpers.specification
import
create_work_specifications_for_group
from
rest_framework.status
import
HTTP_302_FOUND
class
GroupUpdatePropagation
(
dtest
.
TestCase
):
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
setUp
(
self
,
_
):
self
.
user
,
_
=
User
.
objects
.
get_or_create
()
...
...
@@ -20,7 +22,6 @@ class GroupUpdatePropagation(dtest.TestCase):
name
=
"
Example
"
,
url
=
"
https://example.com
"
,
access_token
=
"
TopSecret
"
)
self
.
group
,
_
=
Group
.
objects
.
get_or_create
(
name
=
"
SomeGroup
"
,
processing_site
=
self
.
site
,
...
...
@@ -29,10 +30,15 @@ class GroupUpdatePropagation(dtest.TestCase):
)
self
.
specs
=
create_work_specifications_for_group
(
group
=
self
.
group
,
created_by
=
self
.
user
,
obs_ids
=
[
"
123
"
,
"
456
"
,
"
789
"
],
batch_size
=
4
group
=
self
.
group
,
created_by
=
self
.
user
,
obs_ids
=
[
"
123
"
,
"
456
"
,
"
789
"
],
batch_size
=
4
,
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_group_workflow_propagation
(
self
,
_
):
data
=
{
...
...
@@ -40,21 +46,28 @@ class GroupUpdatePropagation(dtest.TestCase):
"
processing_site
"
:
"
Example
"
,
"
selected_workflow_tag
"
:
"
NewTestTag
"
,
"
selected_workflow
"
:
"
NewWorkflow
"
,
"
action
"
:
"
Create
"
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
selected_workflow
,
data
[
"
selected_workflow
"
])
self
.
assertEqual
(
ws
.
selected_workflow_tag
,
data
[
"
selected_workflow_tag
"
])
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_atdb_site_propagation
(
self
,
_
):
new_site
,
_
=
ATDBProcessingSite
.
objects
.
get_or_create
(
name
=
"
Other
"
,
url
=
"
https://example.com
"
,
access_token
=
"
TopSecret
"
...
...
@@ -65,19 +78,29 @@ class GroupUpdatePropagation(dtest.TestCase):
"
processing_site
"
:
new_site
.
name
,
"
selected_workflow_tag
"
:
"
NewTestTag
"
,
"
selected_workflow
"
:
"
NewWorkflow
"
,
"
action
"
:
"
Create
"
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
processing_site
,
new_site
,
"
Processing site not updated
"
)
self
.
assertEqual
(
ws
.
processing_site
,
new_site
,
"
Processing site not updated
"
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_predecessor_propagation
(
self
,
_
):
pre_ws
=
WorkSpecification
.
objects
.
create
()
...
...
@@ -87,14 +110,164 @@ class GroupUpdatePropagation(dtest.TestCase):
"
selected_workflow_tag
"
:
self
.
group
.
selected_workflow_tag
,
"
selected_workflow
"
:
self
.
group
.
selected_workflow
,
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
predecessor_specification
"
:
pre_ws
.
pk
"
predecessor_specification
"
:
pre_ws
.
pk
,
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
predecessor_specification
,
pre_ws
,
"
Predecessor is not updated
"
)
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_project_propagation
(
self
,
_
):
new_project
=
"
Kerbal Space Program 3
"
data
=
{
"
name
"
:
"
Example
"
,
"
processing_site
"
:
self
.
group
.
processing_site
,
"
selected_workflow_tag
"
:
self
.
group
.
selected_workflow_tag
,
"
selected_workflow
"
:
self
.
group
.
selected_workflow
,
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
project
"
:
new_project
,
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
filters
.
get
(
"
project
"
),
new_project
,
"
Project filter is not updated
"
)
# TODO: check if the define_specification is ran for this WS
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_activity_propagation
(
self
,
_
):
new_activity
=
"
Warp9
"
data
=
{
"
name
"
:
"
Example
"
,
"
processing_site
"
:
self
.
group
.
processing_site
,
"
selected_workflow_tag
"
:
self
.
group
.
selected_workflow_tag
,
"
selected_workflow
"
:
self
.
group
.
selected_workflow
,
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
activity
"
:
new_activity
,
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
filters
.
get
(
"
activity
"
),
new_activity
,
"
Activity filter is not updated
"
,
)
# TODO: check if the define_specification is ran for this WS
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_dataproduct_type_propagation
(
self
,
_
):
new_type
=
"
SpuriousCommunication
"
data
=
{
"
name
"
:
"
Example
"
,
"
processing_site
"
:
self
.
group
.
processing_site
,
"
selected_workflow_tag
"
:
self
.
group
.
selected_workflow_tag
,
"
selected_workflow
"
:
self
.
group
.
selected_workflow
,
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
dataproduct_type
"
:
new_type
,
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
filters
.
get
(
"
dataproduct_type
"
),
new_type
,
"
Dataproduct Type filter is not updated
"
,
)
# TODO: check if the define_specification is ran for this WS
@mock.patch
(
"
lofardata.task.tasks.define_work_specification.delay
"
,
side_effect
=
mocked_delay
)
def
test_dataproduct_location_propagation
(
self
,
_
):
new_location
=
"
Mars
"
data
=
{
"
name
"
:
"
Example
"
,
"
processing_site
"
:
self
.
group
.
processing_site
,
"
selected_workflow_tag
"
:
self
.
group
.
selected_workflow_tag
,
"
selected_workflow
"
:
self
.
group
.
selected_workflow
,
"
action
"
:
"
Create
"
,
# FIXME: when pressing the update btn in the app, it uses action=Create???
"
location
"
:
new_location
,
}
self
.
client
.
force_login
(
self
.
user
)
res
=
self
.
client
.
post
(
reverse
(
"
group-update
"
,
kwargs
=
{
"
pk
"
:
self
.
group
.
pk
}),
data
=
data
)
self
.
assertEqual
(
res
.
status_code
,
HTTP_302_FOUND
,
"
Update should redirect
"
)
self
.
assertEqual
(
res
.
get
(
"
Location
"
),
reverse
(
"
index
"
),
"
Update should redirect to index page
"
,
)
for
ws
in
self
.
specs
:
ws
.
refresh_from_db
()
self
.
assertEqual
(
ws
.
predecessor_specification
,
pre_ws
,
"
Predecessor is not updated
"
)
self
.
assertEqual
(
ws
.
filters
.
get
(
"
location
"
),
new_location
,
"
Location filter is not updated
"
,
)
# TODO: check if the define_specification is ran for this WS
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