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
277e082c
Commit
277e082c
authored
1 year ago
by
Nico Vermaas
Browse files
Options
Downloads
Patches
Plain Diff
add unittests
parent
04ccd8e2
No related branches found
No related tags found
1 merge request
!334
updates after demo to SDCO
Pipeline
#69000
passed
1 year ago
Stage: test
Stage: build
Stage: deploy_to_test
Stage: deploy_to_production
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
atdb/taskdatabase/models.py
+6
-5
6 additions, 5 deletions
atdb/taskdatabase/models.py
atdb/taskdatabase/tests/test_path_to_lta.py
+31
-0
31 additions, 0 deletions
atdb/taskdatabase/tests/test_path_to_lta.py
with
37 additions
and
5 deletions
atdb/taskdatabase/models.py
+
6
−
5
View file @
277e082c
...
...
@@ -304,17 +304,18 @@ class Task(models.Model):
return
None
@property
def
path_to_lta
(
self
):
def
sasid_
path_to_lta
(
self
):
"""
check if any task belonging to this sas_id already has a
'
path_to_lta
'
setting
"""
try
:
for
task
in
Task
.
objects
.
filter
(
sas_id
=
self
.
sas_id
):
if
task
.
archive
[
'
path_to_lta
'
]
:
try
:
try
:
if
task
.
archive
[
'
path_to_lta
'
]
:
return
task
.
archive
[
'
path_to_lta
'
]
except
:
pass
except
:
# if 'path_to_lta' is not found, or 'archive' is empty, continue to the next task
pass
except
:
return
None
...
...
This diff is collapsed.
Click to expand it.
atdb/taskdatabase/tests/test_path_to_lta.py
0 → 100644
+
31
−
0
View file @
277e082c
from
django.test
import
TestCase
from
taskdatabase.models
import
Task
,
Workflow
class
TaskModelTestCase
(
TestCase
):
def
setUp
(
self
):
# Create tasks for testing
# the first 2 have no valid path set
self
.
task1
=
Task
.
objects
.
create
(
sas_id
=
12345
,
archive
=
{})
self
.
task2
=
Task
.
objects
.
create
(
sas_id
=
12345
,
archive
=
{
'
path_to_lta
'
:
None
})
# this task has a valid path_to_lta set
self
.
task3
=
Task
.
objects
.
create
(
sas_id
=
12345
,
archive
=
{
'
path_to_lta
'
:
'
/sample/path
'
})
# this sasid has no path_to_lta set at all
self
.
task4
=
Task
.
objects
.
create
(
sas_id
=
66666
,
archive
=
{})
self
.
task5
=
Task
.
objects
.
create
(
sas_id
=
66666
,
archive
=
{})
def
test_path_to_lta_with_path
(
self
):
# if only one of the tasks has a path_to_lta, then the other tasks should also return that path
for
task
in
Task
.
objects
.
filter
(
sas_id
=
12345
):
result
=
task
.
sasid_path_to_lta
self
.
assertEqual
(
result
,
'
/sample/path
'
)
def
test_path_to_lta_without_path
(
self
):
# if one of the tasks has 'path_to_lta' set, then return None
for
task
in
Task
.
objects
.
filter
(
sas_id
=
66666
):
result
=
task
.
sasid_path_to_lta
self
.
assertEqual
(
result
,
None
)
\ 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