Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
112d49d3
Commit
112d49d3
authored
Jul 11, 2013
by
Steve Komarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up test code
parent
f57a3875
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/edinsights/core/tests.py
+8
-8
No files found.
src/edinsights/core/tests.py
View file @
112d49d3
...
...
@@ -16,7 +16,7 @@ from celery.task import periodic_task
@cron
(
run_every
=
timedelta
(
seconds
=
1
))
def
test_cron_task
(
*
args
):
""" Simple task that gets executed by the scheduler (celery beat).
The test case test_cron
defined below
verifies that the execution
The test case test_cron verifies that the execution
has taken place.
Defined outside of the SimpleTest class because current support of celery decorators
...
...
@@ -30,7 +30,7 @@ def test_cron_task(*args):
@memoize_query
(
60
)
def
test_cron_memoize_task
(
*
args
):
""" Simple task that gets executed by the scheduler (celery beat).
The test case test_cron_and_memoize
defined below
verifies that the execution
The test case test_cron_and_memoize verifies that the execution
has taken place.
Defined outside of the SimpleTest class because current support of celery decorators
...
...
@@ -44,18 +44,18 @@ def test_cron_memoize_task(*args):
return
42
def
run_celery_beat
(
seconds
=
3
,
verbose
=
False
):
""" Runs the task scheduler celery beat for the specified number of seconds
within
a child process
""" Runs the task scheduler celery beat for the specified number of seconds
as
a child process
"""
import
os
with
open
(
os
.
devnull
,
'w'
)
as
devnull
:
from
subprocess
import
Popen
command
=
[
'python'
,
'manage.py'
,
'celery'
,
'worker'
,
'-B'
,
'--loglevel=INFO'
,
'--settings=testsettings'
,]
if
verbose
:
supress_output_args
=
{}
sup
p
ress_output_args
=
{}
else
:
supress_output_args
=
{
'stdout'
:
devnull
,
'stderr'
:
devnull
}
sup
p
ress_output_args
=
{
'stdout'
:
devnull
,
'stderr'
:
devnull
}
celery_beat_process
=
Popen
(
command
,
**
supress_output_args
)
celery_beat_process
=
Popen
(
command
,
**
sup
p
ress_output_args
)
# give time to celery beat to execute test_cron_task
from
time
import
sleep
...
...
@@ -161,7 +161,7 @@ class SimpleTest(TestCase):
ncalls
=
len
(
timestamps
)
self
.
assertGreaterEqual
(
ncalls
,
2
)
last_call
=
float
(
timestamps
[
-
1
]
.
rstrip
())
self
.
assertAlmostEqual
(
last_call
,
time
.
time
(),
delta
=
10
)
self
.
assertAlmostEqual
(
last_call
,
time
.
time
(),
delta
=
10
0
)
def
test_cron_and_memoize
(
self
):
...
...
@@ -182,7 +182,7 @@ class SimpleTest(TestCase):
ncalls
=
len
(
timestamps
)
self
.
assertEqual
(
ncalls
,
1
)
# after the first call all subsequent calls should be cached
last_call
=
float
(
timestamps
[
-
1
]
.
rstrip
())
self
.
assertAlmostEqual
(
last_call
,
time
.
time
(),
delta
=
10
)
self
.
assertAlmostEqual
(
last_call
,
time
.
time
(),
delta
=
10
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment