Skip to content
GitLab
Explore
Sign in
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
atdb-ldv
Commits
3afd094c
Commit
3afd094c
authored
1 year ago
by
Nico Vermaas
Browse files
Options
Downloads
Patches
Plain Diff
add unit tests
parent
af997bd5
No related branches found
No related tags found
1 merge request
!311
SDC-937 many-to-one join-output-tasks
Pipeline
#53053
passed
1 year ago
Stage: build
Stage: deploy_to_test
Stage: deploy_to_production
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
atdb/taskdatabase/tests/test_models_joins.py
+54
-0
54 additions, 0 deletions
atdb/taskdatabase/tests/test_models_joins.py
with
54 additions
and
0 deletions
atdb/taskdatabase/tests/test_models_joins.py
0 → 100644
+
54
−
0
View file @
3afd094c
from
django.test
import
TestCase
import
json
from
taskdatabase.models
import
Workflow
,
Task
class
TestJoinedTasks
(
TestCase
):
@classmethod
def
setUpTestData
(
cls
):
# Set up non-modified objects used by all test methods
workflow
=
Workflow
()
workflow
.
save
()
# create a list of Tasks
Task
.
objects
.
get_or_create
(
sas_id
=
1
,
status
=
'
stored
'
)
Task
.
objects
.
get_or_create
(
sas_id
=
2
,
status
=
'
stored
'
)
Task
.
objects
.
get_or_create
(
sas_id
=
3
,
status
=
'
defined
'
)
def
test_add_input_tasks_to_task
(
self
):
output_task
=
Task
.
objects
.
get
(
sas_id
=
1
)
input_task_1
=
Task
.
objects
.
get
(
sas_id
=
2
)
input_task_2
=
Task
.
objects
.
get
(
sas_id
=
3
)
output_task
.
joined_input_tasks
.
set
([
input_task_1
,
input_task_2
])
output_task
.
save
()
# count number of input asks
count_input_tasks
=
output_task
.
joined_input_tasks
.
count
()
self
.
assertEqual
(
count_input_tasks
,
2
)
def
test_join_status_none
(
self
):
output_task
=
Task
.
objects
.
get
(
sas_id
=
1
)
input_task_1
=
Task
.
objects
.
get
(
sas_id
=
2
)
# stored
input_task_2
=
Task
.
objects
.
get
(
sas_id
=
3
)
# defined
output_task
.
joined_input_tasks
.
set
([
input_task_1
,
input_task_2
])
output_task
.
save
()
# one input task on stored, and on on defined, should give: None
self
.
assertEqual
(
output_task
.
joined_status
,
None
)
def
test_join_status_stored
(
self
):
output_task
=
Task
.
objects
.
get
(
sas_id
=
3
)
input_task_1
=
Task
.
objects
.
get
(
sas_id
=
2
)
# stored
input_task_2
=
Task
.
objects
.
get
(
sas_id
=
1
)
# stored
output_task
.
joined_input_tasks
.
set
([
input_task_1
,
input_task_2
])
output_task
.
save
()
# two input tasks 'stored', should give: 'stored'
self
.
assertEqual
(
output_task
.
joined_status
,
"
stored
"
)
\ No newline at end of file
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