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
f0b44920
Commit
f0b44920
authored
Mar 18, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7381 from edx/will/ecom-601
Copy changes to the activation email
parents
4d2969b0
c37dc913
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
20 deletions
+95
-20
common/djangoapps/student/tests/test_email.py
+69
-0
lms/templates/emails/activation_email.txt
+22
-19
openedx/core/djangoapps/user_api/tests/test_views.py
+4
-1
No files found.
common/djangoapps/student/tests/test_email.py
View file @
f0b44920
...
...
@@ -8,6 +8,8 @@ from student.views import (
reactivation_email_for_user
,
change_email_request
,
do_email_change_request
,
confirm_email_change
)
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.test
import
TestCase
,
TransactionTestCase
from
django.test.client
import
RequestFactory
...
...
@@ -62,6 +64,73 @@ class EmailTestMixin(object):
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
(
'django.contrib.auth.models.User.email_user'
)
class
ReactivationEmailTests
(
EmailTestMixin
,
TestCase
):
...
...
lms/templates/emails/activation_email.txt
View file @
f0b44920
...
...
@@ -2,9 +2,11 @@
<%! from django.utils.translation import ugettext as _ %>
${_("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"
" (you may also copy and paste the link into your browser's address"
" bar).").format(platform_name=settings.PLATFORM_NAME)}
${_("Change your life and start learning today by activating your "
"{platform_name} account. Click on the link below or copy and "
"paste it into your browser's address bar.").format(
platform_name=settings.PLATFORM_NAME
)}
% if is_secure:
https://${ site }/activate/${ key }
...
...
@@ -12,29 +14,30 @@ ${_("To get started, please activate your account by clicking on the link below"
http://${ site }/activate/${ key }
% endif
% if settings.PLATFORM_NAME == "edX":
${_("Activation ensures that you can register for {platform_name} courses and"
" access the courseware."
" If you require assistance, please use our web form at"
" {contact_us} or email {info_address}.").format(
platform_name=settings.PLATFORM_NAME,
contact_us='https://www.edx.org/contact-us',
info_address=settings.CONTACT_EMAIL
)}
% if settings.FEATURES.get('IS_EDX_DOMAIN'):
${_("After you activate your account, you can sign up for "
"and take any of the hundreds of courses {platform_name} offers."
).format(platform_name=settings.PLATFORM_NAME)}
${_("If you need help, please use our web form at "
"{contact_us_url} or email {info_email_address}."
).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(
platform_name=settings.PLATFORM_NAME
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 "
"attempted to create an {platform_name} account using this email address. If you "
"did not attempt to create this account and do not activate the account, "
"you will no longer receive emails from {platform_name}.").format(
platform_name=settings.PLATFORM_NAME,
site_name=settings.SITE_NAME
)}
"attempted to create an {platform_name} account using this email address."
).format(
site_name=settings.SITE_NAME,
platform_name=settings.PLATFORM_NAME
)}
% 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 "
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
f0b44920
...
...
@@ -1302,7 +1302,10 @@ class RegistrationViewTest(ApiTestCase):
sent_email
=
mail
.
outbox
[
0
]
self
.
assertEqual
(
sent_email
.
to
,
[
self
.
EMAIL
])
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
(
{
"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