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
87a72b7e
Commit
87a72b7e
authored
Oct 10, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename some constants, and refactor bulk email task flow.
parent
bc599a06
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
14 deletions
+19
-14
lms/djangoapps/bulk_email/tasks.py
+0
-0
lms/djangoapps/bulk_email/tests/test_email.py
+1
-1
lms/djangoapps/bulk_email/tests/test_err_handling.py
+3
-3
lms/djangoapps/bulk_email/tests/test_tasks.py
+4
-4
lms/envs/aws.py
+4
-3
lms/envs/common.py
+7
-3
No files found.
lms/djangoapps/bulk_email/tasks.py
View file @
87a72b7e
This diff is collapsed.
Click to expand it.
lms/djangoapps/bulk_email/tests/test_email.py
View file @
87a72b7e
...
...
@@ -243,7 +243,7 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase):
[
self
.
instructor
.
email
]
+
[
s
.
email
for
s
in
self
.
staff
]
+
[
s
.
email
for
s
in
self
.
students
]
)
@override_settings
(
EMAILS_PER_TASK
=
3
,
EMAILS_PER_QUERY
=
7
)
@override_settings
(
BULK_EMAIL_EMAILS_PER_TASK
=
3
,
BULK_EMAIL_
EMAILS_PER_QUERY
=
7
)
@patch
(
'bulk_email.tasks.increment_subtask_status'
)
def
test_chunked_queries_send_numerous_emails
(
self
,
email_mock
):
"""
...
...
lms/djangoapps/bulk_email/tests/test_err_handling.py
View file @
87a72b7e
...
...
@@ -76,7 +76,7 @@ class TestEmailErrors(ModuleStoreTestCase):
# have every fourth email fail due to blacklisting:
get_conn
.
return_value
.
send_messages
.
side_effect
=
cycle
([
SMTPDataError
(
554
,
"Email address is blacklisted"
),
None
,
None
,
None
])
students
=
[
UserFactory
()
for
_
in
xrange
(
settings
.
EMAILS_PER_TASK
)]
students
=
[
UserFactory
()
for
_
in
xrange
(
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
)]
for
student
in
students
:
CourseEnrollmentFactory
.
create
(
user
=
student
,
course_id
=
self
.
course
.
id
)
...
...
@@ -93,9 +93,9 @@ class TestEmailErrors(ModuleStoreTestCase):
# Test that after the rejected email, the rest still successfully send
((
_initial_results
),
kwargs
)
=
result
.
call_args
self
.
assertEquals
(
kwargs
[
'skipped'
],
0
)
expected_fails
=
int
((
settings
.
EMAILS_PER_TASK
+
3
)
/
4.0
)
expected_fails
=
int
((
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
+
3
)
/
4.0
)
self
.
assertEquals
(
kwargs
[
'failed'
],
expected_fails
)
self
.
assertEquals
(
kwargs
[
'succeeded'
],
settings
.
EMAILS_PER_TASK
-
expected_fails
)
self
.
assertEquals
(
kwargs
[
'succeeded'
],
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
-
expected_fails
)
@patch
(
'bulk_email.tasks.get_connection'
,
autospec
=
True
)
@patch
(
'bulk_email.tasks.send_course_email.retry'
)
...
...
lms/djangoapps/bulk_email/tests/test_tasks.py
View file @
87a72b7e
...
...
@@ -189,7 +189,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def
test_successful
(
self
):
# Select number of emails to fit into a single subtask.
num_emails
=
settings
.
EMAILS_PER_TASK
num_emails
=
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
# We also send email to the instructor:
self
.
_create_students
(
num_emails
-
1
)
with
patch
(
'bulk_email.tasks.get_connection'
,
autospec
=
True
)
as
get_conn
:
...
...
@@ -198,7 +198,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def
test_unactivated_user
(
self
):
# Select number of emails to fit into a single subtask.
num_emails
=
settings
.
EMAILS_PER_TASK
num_emails
=
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
# We also send email to the instructor:
students
=
self
.
_create_students
(
num_emails
-
1
)
# mark a student as not yet having activated their email:
...
...
@@ -211,7 +211,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def
test_skipped
(
self
):
# Select number of emails to fit into a single subtask.
num_emails
=
settings
.
EMAILS_PER_TASK
num_emails
=
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
# We also send email to the instructor:
students
=
self
.
_create_students
(
num_emails
-
1
)
# have every fourth student optout:
...
...
@@ -227,7 +227,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def
_test_email_address_failures
(
self
,
exception
):
"""Test that celery handles bad address errors by failing and not retrying."""
# Select number of emails to fit into a single subtask.
num_emails
=
settings
.
EMAILS_PER_TASK
num_emails
=
settings
.
BULK_EMAIL_
EMAILS_PER_TASK
# We also send email to the instructor:
self
.
_create_students
(
num_emails
-
1
)
expected_fails
=
int
((
num_emails
+
3
)
/
4.0
)
...
...
lms/envs/aws.py
View file @
87a72b7e
...
...
@@ -139,9 +139,9 @@ PAID_COURSE_REGISTRATION_CURRENCY = ENV_TOKENS.get('PAID_COURSE_REGISTRATION_CUR
PAID_COURSE_REGISTRATION_CURRENCY
)
# Bulk Email overrides
DEFAULT_BULK_FROM_EMAIL
=
ENV_TOKENS
.
get
(
'DEFAULT_BULK_FROM_EMAIL'
,
DEFAULT_BULK
_FROM_EMAIL
)
EMAILS_PER_TASK
=
ENV_TOKENS
.
get
(
'EMAILS_PER_TASK'
,
EMAILS_PER_TASK
)
EMAILS_PER_QUERY
=
ENV_TOKENS
.
get
(
'EMAILS_PER_QUERY'
,
EMAILS_PER_QUERY
)
BULK_EMAIL_DEFAULT_FROM_EMAIL
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_DEFAULT_FROM_EMAIL'
,
BULK_EMAIL_DEFAULT
_FROM_EMAIL
)
BULK_EMAIL_EMAILS_PER_TASK
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_EMAILS_PER_TASK'
,
BULK_EMAIL_
EMAILS_PER_TASK
)
BULK_EMAIL_EMAILS_PER_QUERY
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_EMAILS_PER_QUERY'
,
BULK_EMAIL_
EMAILS_PER_QUERY
)
BULK_EMAIL_DEFAULT_RETRY_DELAY
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_DEFAULT_RETRY_DELAY'
,
BULK_EMAIL_DEFAULT_RETRY_DELAY
)
BULK_EMAIL_MAX_RETRIES
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_MAX_RETRIES'
,
BULK_EMAIL_MAX_RETRIES
)
BULK_EMAIL_INFINITE_RETRY_CAP
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_INFINITE_RETRY_CAP'
,
BULK_EMAIL_INFINITE_RETRY_CAP
)
...
...
@@ -149,6 +149,7 @@ BULK_EMAIL_LOG_SENT_EMAILS = ENV_TOKENS.get('BULK_EMAIL_LOG_SENT_EMAILS', BULK_E
BULK_EMAIL_RETRY_DELAY_BETWEEN_SENDS
=
ENV_TOKENS
.
get
(
'BULK_EMAIL_RETRY_DELAY_BETWEEN_SENDS'
,
BULK_EMAIL_RETRY_DELAY_BETWEEN_SENDS
)
# We want Bulk Email running on the high-priority queue, so we define the
# routing key that points to it. At the moment, the name is the same.
# We have to reset the value here, since we have changed the value of the queue name.
BULK_EMAIL_ROUTING_KEY
=
HIGH_PRIORITY_QUEUE
# Theme overrides
...
...
lms/envs/common.py
View file @
87a72b7e
...
...
@@ -798,9 +798,13 @@ CELERYD_HIJACK_ROOT_LOGGER = False
################################ Bulk Email ###################################
DEFAULT_BULK_FROM_EMAIL
=
'no-reply@courseupdates.edx.org'
EMAILS_PER_TASK
=
100
EMAILS_PER_QUERY
=
1000
# Suffix used to construct 'from' email address for bulk emails.
# A course-specific identifier is prepended.
BULK_EMAIL_DEFAULT_FROM_EMAIL
=
'no-reply@courseupdates.edx.org'
# Parameters for breaking down course enrollment into subtasks.
BULK_EMAIL_EMAILS_PER_TASK
=
100
BULK_EMAIL_EMAILS_PER_QUERY
=
1000
# Initial delay used for retrying tasks. Additional retries use
# longer delays. Value is in seconds.
...
...
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