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
edx
edx-platform
Commits
08d31e1a
Commit
08d31e1a
authored
Oct 30, 2017
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedules: Tests for Course Update messages
parent
03e496bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
14 deletions
+61
-14
openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py
+0
-0
openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py
+37
-0
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+4
-1
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+9
-7
openedx/core/djangoapps/schedules/management/commands/tests/upsell_base.py
+1
-1
openedx/core/djangoapps/schedules/resolvers.py
+2
-2
openedx/core/djangoapps/schedules/tasks.py
+1
-1
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt
+5
-2
openedx/core/djangoapps/schedules/tests/factories.py
+2
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py
View file @
08d31e1a
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py
0 → 100644
View file @
08d31e1a
from
mock
import
patch
from
unittest
import
skipUnless
from
django.conf
import
settings
from
openedx.core.djangoapps.schedules
import
resolvers
,
tasks
from
openedx.core.djangoapps.schedules.management.commands
import
send_course_update
as
nudge
from
openedx.core.djangoapps.schedules.management.commands.tests.send_email_base
import
ScheduleSendEmailTestBase
from
openedx.core.djangoapps.schedules.management.commands.tests.upsell_base
import
ScheduleUpsellTestMixin
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@skip_unless_lms
@skipUnless
(
'openedx.core.djangoapps.schedules.apps.SchedulesConfig'
in
settings
.
INSTALLED_APPS
,
"Can't test schedules if the app isn't installed"
,
)
class
TestSendCourseUpdate
(
ScheduleUpsellTestMixin
,
ScheduleSendEmailTestBase
):
__test__
=
True
# pylint: disable=protected-access
tested_resolver
=
resolvers
.
CourseUpdateResolver
tested_task
=
tasks
.
ScheduleCourseUpdate
deliver_task
=
tasks
.
_course_update_schedule_send
tested_command
=
nudge
.
Command
deliver_config
=
'deliver_course_update'
enqueue_config
=
'enqueue_course_update'
expected_offsets
=
xrange
(
-
7
,
-
77
,
-
7
)
queries_deadline_for_each_course
=
True
def
setUp
(
self
):
super
(
TestSendCourseUpdate
,
self
)
.
setUp
()
patcher
=
patch
(
'openedx.core.djangoapps.schedules.resolvers.get_week_highlights'
)
mock_highlights
=
patcher
.
start
()
mock_highlights
.
return_value
=
[
'Highlight {}'
.
format
(
num
+
1
)
for
num
in
range
(
3
)]
self
.
addCleanup
(
patcher
.
stop
)
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
08d31e1a
...
...
@@ -2,7 +2,7 @@ from unittest import skipUnless
from
django.conf
import
settings
from
openedx.core.djangoapps.schedules
import
tasks
from
openedx.core.djangoapps.schedules
import
resolvers
,
tasks
from
openedx.core.djangoapps.schedules.management.commands
import
send_recurring_nudge
as
nudge
from
openedx.core.djangoapps.schedules.management.commands.tests.send_email_base
import
ScheduleSendEmailTestBase
from
openedx.core.djangoapps.schedules.management.commands.tests.upsell_base
import
ScheduleUpsellTestMixin
...
...
@@ -18,9 +18,12 @@ class TestSendRecurringNudge(ScheduleUpsellTestMixin, ScheduleSendEmailTestBase)
__test__
=
True
# pylint: disable=protected-access
tested_resolver
=
resolvers
.
RecurringNudgeResolver
tested_task
=
tasks
.
ScheduleRecurringNudge
deliver_task
=
tasks
.
_recurring_nudge_schedule_send
tested_command
=
nudge
.
Command
deliver_config
=
'deliver_recurring_nudge'
enqueue_config
=
'enqueue_recurring_nudge'
expected_offsets
=
(
-
3
,
-
10
)
consolidates_emails_for_learner
=
True
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
08d31e1a
...
...
@@ -5,11 +5,11 @@ import ddt
from
django.conf
import
settings
from
edx_ace
import
Message
from
edx_ace.utils.date
import
serialize
from
mock
import
Mock
,
patch
from
mock
import
patch
from
opaque_keys.edx.locator
import
CourseLocator
from
course_modes.models
import
CourseMode
from
openedx.core.djangoapps.schedules
import
tasks
from
openedx.core.djangoapps.schedules
import
resolvers
,
tasks
from
openedx.core.djangoapps.schedules.management.commands
import
send_upgrade_reminder
as
reminder
from
openedx.core.djangoapps.schedules.management.commands.tests.send_email_base
import
ScheduleSendEmailTestBase
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleFactory
...
...
@@ -27,6 +27,7 @@ LOG = logging.getLogger(__name__)
class
TestUpgradeReminder
(
ScheduleSendEmailTestBase
):
__test__
=
True
tested_resolver
=
resolvers
.
UpgradeReminderResolver
tested_task
=
tasks
.
ScheduleUpgradeReminder
deliver_task
=
tasks
.
_upgrade_reminder_schedule_send
tested_command
=
reminder
.
Command
...
...
@@ -34,15 +35,16 @@ class TestUpgradeReminder(ScheduleSendEmailTestBase):
enqueue_config
=
'enqueue_upgrade_reminder'
expected_offsets
=
(
2
,)
has_course_queries
=
True
queries_deadline_for_each_course
=
True
consolidates_emails_for_learner
=
True
@ddt.data
(
True
,
False
)
@patch.object
(
tasks
,
'ace'
)
def
test_verified_learner
(
self
,
is_verified
,
mock_ace
):
user
=
UserFactory
.
create
(
id
=
self
.
tested_task
.
num_bins
)
current_day
,
offset
,
target_day
=
self
.
_get_dates
()
current_day
,
offset
,
target_day
,
upgrade_deadline
=
self
.
_get_dates
()
ScheduleFactory
.
create
(
upgrade_deadline
=
target_day
,
upgrade_deadline
=
upgrade_deadline
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user
,
enrollment__mode
=
CourseMode
.
VERIFIED
if
is_verified
else
CourseMode
.
AUDIT
,
...
...
@@ -56,12 +58,12 @@ class TestUpgradeReminder(ScheduleSendEmailTestBase):
self
.
assertEqual
(
mock_ace
.
send
.
called
,
not
is_verified
)
def
test_filter_out_verified_schedules
(
self
):
current_day
,
offset
,
target_day
=
self
.
_get_dates
()
current_day
,
offset
,
target_day
,
upgrade_deadline
=
self
.
_get_dates
()
user
=
UserFactory
.
create
()
schedules
=
[
ScheduleFactory
.
create
(
upgrade_deadline
=
target_day
,
upgrade_deadline
=
upgrade_deadline
,
enrollment__user
=
user
,
enrollment__course__self_paced
=
True
,
enrollment__course__id
=
CourseLocator
(
'edX'
,
'toy'
,
'Course{}'
.
format
(
i
)),
...
...
openedx/core/djangoapps/schedules/management/commands/tests/upsell_base.py
View file @
08d31e1a
...
...
@@ -29,7 +29,7 @@ class ScheduleUpsellTestMixin(object):
def
test_upsell
(
self
,
enable_config
,
testcase
):
DynamicUpgradeDeadlineConfiguration
.
objects
.
create
(
enabled
=
enable_config
)
current_day
,
offset
,
target_day
=
self
.
_get_dates
()
current_day
,
offset
,
target_day
,
_
=
self
.
_get_dates
()
upgrade_deadline
=
None
if
testcase
.
set_deadline
:
upgrade_deadline
=
current_day
+
datetime
.
timedelta
(
days
=
testcase
.
deadline_offset
)
...
...
openedx/core/djangoapps/schedules/resolvers.py
View file @
08d31e1a
...
...
@@ -224,11 +224,11 @@ class InvalidContextError(Exception):
pass
class
ScheduleStart
Resolver
(
BinnedSchedulesBaseResolver
):
class
RecurringNudge
Resolver
(
BinnedSchedulesBaseResolver
):
"""
Send a message to all users whose schedule started at ``self.current_date`` + ``day_offset``.
"""
log_prefix
=
'
Scheduled
Nudge'
log_prefix
=
'
Recurring
Nudge'
schedule_date_field
=
'start'
num_bins
=
RECURRING_NUDGE_NUM_BINS
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
08d31e1a
...
...
@@ -147,7 +147,7 @@ class ScheduleRecurringNudge(ScheduleMessageBaseTask):
num_bins
=
resolvers
.
RECURRING_NUDGE_NUM_BINS
enqueue_config_var
=
'enqueue_recurring_nudge'
log_prefix
=
RECURRING_NUDGE_LOG_PREFIX
resolver
=
resolvers
.
ScheduleStart
Resolver
resolver
=
resolvers
.
RecurringNudge
Resolver
async_send_task
=
_recurring_nudge_schedule_send
def
make_message_type
(
self
,
day_offset
):
...
...
openedx/core/djangoapps/schedules/templates/schedules/edx_ace/courseupdate/email/body.txt
View file @
08d31e1a
...
...
@@ -4,8 +4,11 @@
Welcome to week {{ week_num }} of our {{ course_name }} course!
Here is what you can look forward to learning this week:
{{ week_summary }}
{% endblocktrans %}
{% for highlight in week_highlights %}
* {{ highlight }}
{% endfor %}
{% include "schedules/edx_ace/common/upsell_cta.txt"%}
openedx/core/djangoapps/schedules/tests/factories.py
View file @
08d31e1a
...
...
@@ -25,3 +25,5 @@ class ScheduleConfigFactory(factory.DjangoModelFactory):
deliver_recurring_nudge
=
True
enqueue_upgrade_reminder
=
True
deliver_upgrade_reminder
=
True
enqueue_course_update
=
True
deliver_course_update
=
True
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