Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
a50db05d
Commit
a50db05d
authored
1 year ago
by
Mohammad Torkashvand
Browse files
Options
Downloads
Patches
Plain Diff
Add celery worker and celery beat
parent
c530567b
No related branches found
No related tags found
No related merge requests found
Pipeline
#84457
failed
1 year ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
23
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/schedules/__init__.py
+0
-0
0 additions, 0 deletions
test/schedules/__init__.py
test/schedules/test_scheduling.py
+37
-0
37 additions, 0 deletions
test/schedules/test_scheduling.py
tox.ini
+1
-0
1 addition, 0 deletions
tox.ini
with
38 additions
and
0 deletions
test/schedules/__init__.py
0 → 100644
+
0
−
0
View file @
a50db05d
This diff is collapsed.
Click to expand it.
test/schedules/test_scheduling.py
0 → 100644
+
37
−
0
View file @
a50db05d
from
unittest.mock
import
patch
import
pytest
from
gso.schedules.scheduling
import
scheduler
@pytest.fixture
def
mock_celery
():
with
patch
(
"
gso.schedules.scheduling.current_app
"
)
as
mock_app
:
yield
mock_app
def
test_scheduler_updates_beat_schedule
(
mock_celery
):
mock_celery
.
conf
.
beat_schedule
=
{}
@scheduler
(
name
=
"
A cool task
"
,
minute
=
"
0
"
,
hour
=
"
0
"
,
day_of_week
=
"
*
"
,
day_of_month
=
"
*
"
,
month_of_year
=
"
*
"
)
def
mock_task
():
return
"
task result
"
assert
"
mock_task
"
in
mock_celery
.
conf
.
beat_schedule
scheduled
=
mock_celery
.
conf
.
beat_schedule
[
"
mock_task
"
]
assert
scheduled
[
"
schedule
"
].
minute
==
{
0
}
assert
scheduled
[
"
schedule
"
].
hour
==
{
0
}
assert
scheduled
[
"
task
"
]
==
"
test.schedules.test_scheduling.mock_task
"
assert
scheduled
[
"
name
"
]
==
"
A cool task
"
def
test_scheduled_task_still_works
():
"""
Ensure that the scheduler decorator does not change the behavior of the function it decorates.
"""
@scheduler
(
name
=
"
A cool task
"
,
minute
=
"
0
"
,
hour
=
"
0
"
,
day_of_week
=
"
*
"
,
day_of_month
=
"
*
"
,
month_of_year
=
"
*
"
)
def
mock_task
():
return
"
task result
"
result
=
mock_task
()
assert
result
==
"
task result
"
This diff is collapsed.
Click to expand it.
tox.ini
+
1
−
0
View file @
a50db05d
...
@@ -22,6 +22,7 @@ deps =
...
@@ -22,6 +22,7 @@ deps =
ruff
ruff
isort
isort
types-requests
types-requests
celery-stubs
-r
requirements.txt
-r
requirements.txt
commands
=
commands
=
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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