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
2fbdb8f6
Commit
2fbdb8f6
authored
Nov 16, 2017
by
Alex Dusenbery
Committed by
Alex Dusenbery
Nov 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1590 | Test that we can actually render the forum emails.
parent
c28427fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
lms/djangoapps/discussion/tests/test_tasks.py
+22
-0
No files found.
lms/djangoapps/discussion/tests/test_tasks.py
View file @
2fbdb8f6
...
...
@@ -5,6 +5,7 @@ from datetime import datetime, timedelta
import
json
import
math
from
crum
import
CurrentRequestUserMiddleware
import
ddt
from
django.contrib.sites.models
import
Site
import
mock
...
...
@@ -14,6 +15,7 @@ import lms.lib.comment_client as cc
from
django_comment_common.models
import
ForumsConfig
from
django_comment_common.signals
import
comment_created
from
edx_ace.recipient
import
Recipient
from
edx_ace.renderers
import
EmailRenderer
from
edx_ace.utils
import
date
from
lms.djangoapps.discussion.config.waffle
import
waffle
,
FORUM_RESPONSE_NOTIFICATIONS
,
SEND_NOTIFICATIONS_FOR_COURSE
from
lms.djangoapps.discussion.signals.handlers
import
ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY
...
...
@@ -21,10 +23,13 @@ from lms.djangoapps.discussion.tasks import _should_send_message
from
openedx.core.djangoapps.content.course_overviews.tests.factories
import
CourseOverviewFactory
from
openedx.core.djangoapps.schedules.template_context
import
get_base_template_context
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteConfigurationFactory
from
openedx.core.djangoapps.theming.middleware
import
CurrentSiteThemeMiddleware
from
openedx.core.djangoapps.waffle_utils.testutils
import
override_waffle_flag
from
openedx.core.lib.celery.task_utils
import
emulate_http_request
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
NOW
=
datetime
.
utcnow
()
ONE_HOUR_AGO
=
NOW
-
timedelta
(
hours
=
1
)
TWO_HOURS_AGO
=
NOW
-
timedelta
(
hours
=
2
)
...
...
@@ -211,9 +216,26 @@ class TaskTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
expected_message_context
,
actual_message
.
context
)
self
.
assertEqual
(
expected_recipient
,
actual_message
.
recipient
)
self
.
assertEqual
(
self
.
course
.
language
,
actual_message
.
language
)
self
.
_assert_rendered_email
(
actual_message
)
else
:
self
.
assertFalse
(
self
.
mock_ace_send
.
called
)
def
_assert_rendered_email
(
self
,
message
):
# check that we can actually render the message
middleware_classes
=
[
CurrentRequestUserMiddleware
,
CurrentSiteThemeMiddleware
,
]
with
emulate_http_request
(
site
=
message
.
context
[
'site'
],
user
=
self
.
thread_author
,
middleware_classes
=
middleware_classes
):
rendered_email
=
EmailRenderer
()
.
render
(
message
)
self
.
assertTrue
(
self
.
comment
[
'body'
]
in
rendered_email
.
body_html
)
self
.
assertTrue
(
self
.
comment_author
.
username
in
rendered_email
.
body_html
)
self
.
assertTrue
(
self
.
thread_author
.
username
in
rendered_email
.
body_html
)
self
.
assertTrue
(
self
.
mock_permalink
in
rendered_email
.
body_html
)
self
.
assertTrue
(
message
.
context
[
'site'
]
.
domain
in
rendered_email
.
body_html
)
@override_waffle_flag
(
SEND_NOTIFICATIONS_FOR_COURSE
,
True
)
def
run_should_not_send_email_test
(
self
,
comment_dict
):
self
.
mock_request
.
side_effect
=
make_mock_responder
(
...
...
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