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
c37dc913
Commit
c37dc913
authored
Mar 16, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy changes to the activation email
parent
d2786a64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
18 deletions
+93
-18
common/djangoapps/student/tests/test_email.py
+69
-0
lms/templates/emails/activation_email.txt
+20
-17
openedx/core/djangoapps/user_api/tests/test_views.py
+4
-1
No files found.
common/djangoapps/student/tests/test_email.py
View file @
c37dc913
...
@@ -8,6 +8,8 @@ from student.views import (
...
@@ -8,6 +8,8 @@ from student.views import (
reactivation_email_for_user
,
change_email_request
,
do_email_change_request
,
confirm_email_change
reactivation_email_for_user
,
change_email_request
,
do_email_change_request
,
confirm_email_change
)
)
from
student.models
import
UserProfile
,
PendingEmailChange
from
student.models
import
UserProfile
,
PendingEmailChange
from
django.core.urlresolvers
import
reverse
from
django.core
import
mail
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.test
import
TestCase
,
TransactionTestCase
from
django.test
import
TestCase
,
TransactionTestCase
from
django.test.client
import
RequestFactory
from
django.test.client
import
RequestFactory
...
@@ -62,6 +64,73 @@ class EmailTestMixin(object):
...
@@ -62,6 +64,73 @@ class EmailTestMixin(object):
self
.
addCleanup
(
settings
.
ALLOWED_HOSTS
.
pop
)
self
.
addCleanup
(
settings
.
ALLOWED_HOSTS
.
pop
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
ActivationEmailTests
(
TestCase
):
"""Test sending of the activation email. """
ACTIVATION_SUBJECT
=
"Activate Your edX Account"
# Text fragments we expect in the body of an email
# sent from an OpenEdX installation.
OPENEDX_FRAGMENTS
=
[
"Thank you for signing up for {platform}."
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
"http://edx.org/activate/"
,
(
"if you require assistance, check the help section of the "
"{platform} website"
.
format
(
platform
=
settings
.
PLATFORM_NAME
)
)
]
# Text fragments we expect in the body of an email
# sent from an EdX-controlled domain.
EDX_DOMAIN_FRAGMENTS
=
[
"Thank you for signing up for {platform}"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
"http://edx.org/activate/"
,
"https://www.edx.org/contact-us"
,
"This email was automatically sent by edx.org"
]
def
setUp
(
self
):
super
(
ActivationEmailTests
,
self
)
.
setUp
()
def
test_activation_email
(
self
):
self
.
_create_account
()
self
.
_assert_activation_email
(
self
.
ACTIVATION_SUBJECT
,
self
.
OPENEDX_FRAGMENTS
)
@patch.dict
(
settings
.
FEATURES
,
{
'IS_EDX_DOMAIN'
:
True
})
def
test_activation_email_edx_domain
(
self
):
self
.
_create_account
()
self
.
_assert_activation_email
(
self
.
ACTIVATION_SUBJECT
,
self
.
EDX_DOMAIN_FRAGMENTS
)
def
_create_account
(
self
):
"""Create an account, triggering the activation email. """
url
=
reverse
(
'create_account'
)
params
=
{
'username'
:
'test_user'
,
'email'
:
'test_user@example.com'
,
'password'
:
'edx'
,
'name'
:
'Test User'
,
'honor_code'
:
True
,
'terms_of_service'
:
True
}
resp
=
self
.
client
.
post
(
url
,
params
)
self
.
assertEqual
(
resp
.
status_code
,
200
,
msg
=
u"Could not create account (status {status}). The response was {response}"
.
format
(
status
=
resp
.
status_code
,
response
=
resp
.
content
)
)
def
_assert_activation_email
(
self
,
subject
,
body_fragments
):
"""Verify that the activation email was sent. """
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
msg
=
mail
.
outbox
[
0
]
self
.
assertEqual
(
msg
.
subject
,
subject
)
for
fragment
in
body_fragments
:
self
.
assertIn
(
fragment
,
msg
.
body
)
@patch
(
'student.views.render_to_string'
,
Mock
(
side_effect
=
mock_render_to_string
,
autospec
=
True
))
@patch
(
'student.views.render_to_string'
,
Mock
(
side_effect
=
mock_render_to_string
,
autospec
=
True
))
@patch
(
'django.contrib.auth.models.User.email_user'
)
@patch
(
'django.contrib.auth.models.User.email_user'
)
class
ReactivationEmailTests
(
EmailTestMixin
,
TestCase
):
class
ReactivationEmailTests
(
EmailTestMixin
,
TestCase
):
...
...
lms/templates/emails/activation_email.txt
View file @
c37dc913
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
<%! from django.utils.translation import ugettext as _ %>
<%! from django.utils.translation import ugettext as _ %>
${_("Thank you for signing up for {platform_name}.").format(platform_name=settings.PLATFORM_NAME)}
${_("Thank you for signing up for {platform_name}.").format(platform_name=settings.PLATFORM_NAME)}
${_("To get started, please activate your account by clicking on the link below"
${_("Change your life and start learning today by activating your "
" (you may also copy and paste the link into your browser's address"
"{platform_name} account. Click on the link below or copy and "
" bar).").format(platform_name=settings.PLATFORM_NAME)}
"paste it into your browser's address bar.").format(
platform_name=settings.PLATFORM_NAME
)}
% if is_secure:
% if is_secure:
https://${ site }/activate/${ key }
https://${ site }/activate/${ key }
...
@@ -12,14 +14,16 @@ ${_("To get started, please activate your account by clicking on the link below"
...
@@ -12,14 +14,16 @@ ${_("To get started, please activate your account by clicking on the link below"
http://${ site }/activate/${ key }
http://${ site }/activate/${ key }
% endif
% endif
% if settings.PLATFORM_NAME == "edX":
% if settings.FEATURES.get('IS_EDX_DOMAIN'):
${_("Activation ensures that you can register for {platform_name} courses and"
${_("After you activate your account, you can sign up for "
" access the courseware."
"and take any of the hundreds of courses {platform_name} offers."
" If you require assistance, please use our web form at"
).format(platform_name=settings.PLATFORM_NAME)}
" {contact_us} or email {info_address}.").format(
platform_name=settings.PLATFORM_NAME,
${_("If you need help, please use our web form at "
contact_us='https://www.edx.org/contact-us',
"{contact_us_url} or email {info_email_address}."
info_address=settings.CONTACT_EMAIL
).format(
contact_us_url="https://www.edx.org/contact-us",
info_email_address=settings.CONTACT_EMAIL
)}
)}
${_("We hope you enjoy learning with {platform_name}!").format(
${_("We hope you enjoy learning with {platform_name}!").format(
...
@@ -29,12 +33,11 @@ ${_("We hope you enjoy learning with {platform_name}!").format(
...
@@ -29,12 +33,11 @@ ${_("We hope you enjoy learning with {platform_name}!").format(
${_("The {platform_name} Team").format(platform_name=settings.PLATFORM_NAME)}
${_("The {platform_name} Team").format(platform_name=settings.PLATFORM_NAME)}
${_("This email was automatically sent by {site_name} because someone "
${_("This email was automatically sent by {site_name} because someone "
"attempted to create an {platform_name} account using this email address. If you "
"attempted to create an {platform_name} account using this email address."
"did not attempt to create this account and do not activate the account, "
).format(
"you will no longer receive emails from {platform_name}.").format(
site_name=settings.SITE_NAME,
platform_name=settings.PLATFORM_NAME,
platform_name=settings.PLATFORM_NAME
site_name=settings.SITE_NAME
)}
)}
% elif stanford_theme_enabled(): ## Temporary hack until we develop a better way to adjust language
% elif stanford_theme_enabled(): ## Temporary hack until we develop a better way to adjust language
${_("If you didn't request this, you don't need to do anything; you won't "
${_("If you didn't request this, you don't need to do anything; you won't "
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
c37dc913
...
@@ -1306,7 +1306,10 @@ class RegistrationViewTest(ApiTestCase):
...
@@ -1306,7 +1306,10 @@ class RegistrationViewTest(ApiTestCase):
sent_email
=
mail
.
outbox
[
0
]
sent_email
=
mail
.
outbox
[
0
]
self
.
assertEqual
(
sent_email
.
to
,
[
self
.
EMAIL
])
self
.
assertEqual
(
sent_email
.
to
,
[
self
.
EMAIL
])
self
.
assertEqual
(
sent_email
.
subject
,
"Activate Your edX Account"
)
self
.
assertEqual
(
sent_email
.
subject
,
"Activate Your edX Account"
)
self
.
assertIn
(
"activate your account"
,
sent_email
.
body
)
self
.
assertIn
(
u"activating your {platform} account"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
sent_email
.
body
)
@ddt.data
(
@ddt.data
(
{
"email"
:
""
},
{
"email"
:
""
},
...
...
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