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
35b78c12
Commit
35b78c12
authored
1 year ago
by
Nico Vermaas
Browse files
Options
Downloads
Patches
Plain Diff
unittests for priority
parent
51a26922
No related branches found
No related tags found
3 merge requests
!333
get all the new changes from master into the branch
,
!330
still a bug
,
!328
Solving Feature SDCP-239
Pipeline
#68346
passed
1 year ago
Stage: test
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_priority.py
+59
-0
59 additions, 0 deletions
atdb/taskdatabase/tests/test_priority.py
with
59 additions
and
0 deletions
atdb/taskdatabase/tests/test_priority.py
0 → 100644
+
59
−
0
View file @
35b78c12
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.contrib.auth.models
import
User
from
django.contrib.auth.decorators
import
login_required
from
django.test
import
Client
from
taskdatabase.models
import
Task
,
Workflow
class
ChangePriorityViewTest
(
TestCase
):
def
setUp
(
self
):
# Create a test user
self
.
user
=
User
.
objects
.
create_user
(
username
=
'
testuser
'
,
password
=
'
testpassword
'
)
# Create a test workflow
workflow_requantisation
=
Workflow
(
workflow_uri
=
"
psrfits_requantisation
"
)
workflow_requantisation
.
save
()
# Create a test task
self
.
task
=
Task
.
objects
.
create
(
filter
=
'
a
'
,
sas_id
=
54321
,
status
=
'
stored
'
,
workflow
=
workflow_requantisation
,
priority
=
1
)
self
.
task
=
Task
.
objects
.
create
(
filter
=
'
b
'
,
sas_id
=
54321
,
status
=
'
stored
'
,
workflow
=
workflow_requantisation
,
priority
=
1
)
# Login the test user
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
'
testuser
'
,
password
=
'
testpassword
'
)
def
test_change_priority
(
self
):
# Set up the URL for the view
url
=
reverse
(
'
task-change-priority
'
,
kwargs
=
{
'
pk
'
:
self
.
task
.
pk
,
'
priority_change
'
:
2
,
'
page
'
:
1
})
# Call the view using the client
response
=
self
.
client
.
get
(
url
)
# Check if the task priority has been updated
updated_task
=
Task
.
objects
.
get
(
pk
=
self
.
task
.
pk
)
self
.
assertEqual
(
updated_task
.
priority
,
3
)
def
test_change_priority_negative_priority
(
self
):
# Set up the URL for the view with a negative priority_change value
url
=
reverse
(
'
task-change-priority
'
,
kwargs
=
{
'
pk
'
:
self
.
task
.
pk
,
'
priority_change
'
:
-
2
,
'
page
'
:
0
})
# Call the view using the client
response
=
self
.
client
.
get
(
url
)
# Check if the task priority is set to 0 when priority becomes negative
updated_task
=
Task
.
objects
.
get
(
pk
=
self
.
task
.
pk
)
self
.
assertEqual
(
updated_task
.
priority
,
0
)
def
test_change_priority_sasid
(
self
):
# Set up the URL for the view
url
=
reverse
(
'
task-change-priority-sasid
'
,
kwargs
=
{
'
pk
'
:
self
.
task
.
pk
,
'
priority_change
'
:
2
,
'
page
'
:
1
})
# Call the view using the client
response
=
self
.
client
.
get
(
url
)
# Check if the task priority has been updated
updated_task
=
Task
.
objects
.
get
(
pk
=
self
.
task
.
pk
)
self
.
assertEqual
(
updated_task
.
priority
,
3
)
\ 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