Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
OpenEdx
edx-platform
Commits
50e04d5f
Commit
50e04d5f
authored
Aug 15, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! Add tests of the send_recurring_nudge
parent
a7f1ea03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+10
-3
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
50e04d5f
...
@@ -2,18 +2,20 @@ import datetime
...
@@ -2,18 +2,20 @@ import datetime
from
mock
import
patch
,
Mock
from
mock
import
patch
,
Mock
import
pytz
import
pytz
import
ddt
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
openedx.core.djangoapps.schedules.management.commands
import
send_recurring_nudge
as
nudge
from
openedx.core.djangoapps.schedules.management.commands
import
send_recurring_nudge
as
nudge
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleFactory
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleFactory
@ddt.ddt
class
TestSendRecurringNudge
(
CacheIsolationTestCase
):
class
TestSendRecurringNudge
(
CacheIsolationTestCase
):
# pylint: disable=protected-access
# pylint: disable=protected-access
def
setUp
(
self
):
def
setUp
(
self
):
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
44
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
44
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
17
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
17
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
2
,
15
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
2
,
15
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
...
@@ -58,13 +60,18 @@ class TestSendRecurringNudge(CacheIsolationTestCase):
...
@@ -58,13 +60,18 @@ class TestSendRecurringNudge(CacheIsolationTestCase):
mock_schedule_minute
.
delay
.
assert_any_call
(
3
,
test_time
+
datetime
.
timedelta
(
minutes
=
59
))
mock_schedule_minute
.
delay
.
assert_any_call
(
3
,
test_time
+
datetime
.
timedelta
(
minutes
=
59
))
self
.
assertFalse
(
mock_ace
.
send
.
called
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
1
,
10
,
100
)
@patch.object
(
nudge
,
'ace'
)
@patch.object
(
nudge
,
'ace'
)
@patch.object
(
nudge
,
'_schedule_send'
)
@patch.object
(
nudge
,
'_schedule_send'
)
def
test_schedule_minute
(
self
,
mock_schedule_send
,
mock_ace
):
def
test_schedule_minute
(
self
,
schedule_count
,
mock_schedule_send
,
mock_ace
):
for
_
in
range
(
schedule_count
):
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
34
,
30
,
tzinfo
=
pytz
.
UTC
))
test_time
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
34
,
tzinfo
=
pytz
.
UTC
)
test_time
=
datetime
.
datetime
(
2017
,
8
,
1
,
15
,
34
,
tzinfo
=
pytz
.
UTC
)
with
self
.
assertNumQueries
(
1
):
with
self
.
assertNumQueries
(
1
):
nudge
.
_schedule_minute
(
3
,
test_time
)
nudge
.
_schedule_minute
(
3
,
test_time
)
self
.
assertEqual
(
mock_schedule_send
.
delay
.
call_count
,
1
)
self
.
assertEqual
(
mock_schedule_send
.
delay
.
call_count
,
schedule_count
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@patch.object
(
nudge
,
'ace'
)
@patch.object
(
nudge
,
'ace'
)
...
...
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