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
66e2ebb3
Commit
66e2ebb3
authored
Dec 06, 2017
by
Ahsan Ulhaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch Exception on getting sailthru cookie
LEARNER-3465
parent
ff7fa721
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
lms/djangoapps/email_marketing/signals.py
+5
-1
lms/djangoapps/email_marketing/tests/test_signals.py
+17
-0
No files found.
lms/djangoapps/email_marketing/signals.py
View file @
66e2ebb3
...
...
@@ -82,7 +82,11 @@ def add_email_marketing_cookies(sender, response=None, user=None,
post_parms
[
'cookies'
]
=
{
'anonymous_interest'
:
sailthru_content
}
time_before_call
=
datetime
.
datetime
.
now
()
sailthru_response
=
get_email_cookies_via_sailthru
.
delay
(
user
.
email
,
post_parms
)
try
:
sailthru_response
=
get_email_cookies_via_sailthru
.
delay
(
user
.
email
,
post_parms
)
except
Exception
as
exc
:
# pylint: disable=broad-except
log
.
error
(
"Exception Connecting to celery task:
%
s"
,
unicode
(
exc
))
return
response
try
:
# synchronous call to get result of an asynchronous celery task, with timeout
...
...
lms/djangoapps/email_marketing/tests/test_signals.py
View file @
66e2ebb3
...
...
@@ -172,6 +172,7 @@ class EmailMarketingTests(TestCase):
add_email_marketing_cookies
(
None
,
response
=
response
,
user
=
self
.
user
)
self
.
assertFalse
(
'sailthru_hid'
in
response
.
cookies
)
@patch
(
'email_marketing.tasks.log.error'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_post'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_get'
)
...
...
@@ -195,6 +196,22 @@ class EmailMarketingTests(TestCase):
self
.
assertEquals
(
userparms
[
'vars'
][
'activated'
],
1
)
self
.
assertEquals
(
userparms
[
'lists'
][
'new list'
],
1
)
@patch
(
'email_marketing.tasks.get_email_cookies_via_sailthru.delay'
)
def
test_drop_cookie_task_error
(
self
,
mock_task
):
"""
test that task error is handled
"""
mock_task
.
side_effect
=
Exception
with
LogCapture
(
LOGGER_NAME
,
level
=
logging
.
INFO
)
as
logger
:
add_email_marketing_cookies
(
None
,
response
=
None
,
user
=
self
.
user
)
logger
.
check
(
(
LOGGER_NAME
,
'ERROR'
,
'Exception Connecting to celery task: {exception}'
.
format
(
exception
=
Exception
)
)
)
@patch
(
'email_marketing.tasks.log.error'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_post'
)
@patch
(
'email_marketing.tasks.SailthruClient.api_get'
)
...
...
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