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
8ee682d4
Commit
8ee682d4
authored
May 02, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed and added more tests for bulk email.
LMS-2565
parent
c955fd0b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
0 deletions
+54
-0
lms/djangoapps/bulk_email/tests/test_email.py
+15
-0
lms/djangoapps/bulk_email/tests/test_err_handling.py
+1
-0
lms/djangoapps/instructor/tests/test_api.py
+3
-0
lms/djangoapps/instructor/tests/test_legacy_email.py
+35
-0
No files found.
lms/djangoapps/bulk_email/tests/test_email.py
View file @
8ee682d4
...
...
@@ -41,6 +41,7 @@ class MockCourseEmailResult(object):
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestEmailSendFromDashboard
(
ModuleStoreTestCase
):
"""
Test that emails send correctly.
...
...
@@ -88,6 +89,20 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase):
"""
patch
.
stopall
()
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
True
})
def
test_email_disabled
(
self
):
"""
Test response when email is disabled for course.
"""
test_email
=
{
'action'
:
'Send email'
,
'to_option'
:
'myself'
,
'subject'
:
'test subject for myself'
,
'message'
:
'test message for myself'
}
response
=
self
.
client
.
post
(
self
.
url
,
test_email
)
self
.
assertContains
(
response
,
"Email is not enabled for this course."
)
def
test_send_to_self
(
self
):
"""
Make sure email send to myself goes to myself.
...
...
lms/djangoapps/bulk_email/tests/test_err_handling.py
View file @
8ee682d4
...
...
@@ -38,6 +38,7 @@ class EmailTestException(Exception):
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestEmailErrors
(
ModuleStoreTestCase
):
"""
Test that errors from sending email are handled properly.
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
8ee682d4
...
...
@@ -11,6 +11,7 @@ from urllib import quote
from
django.test
import
TestCase
from
nose.tools
import
raises
from
mock
import
Mock
,
patch
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpRequest
,
HttpResponse
...
...
@@ -99,6 +100,7 @@ class TestCommonExceptions400(unittest.TestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorAPIDenyLevels
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Ensure that users cannot access endpoints they shouldn't be able to.
...
...
@@ -1570,6 +1572,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorSendEmail
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Checks that only instructors have access to email endpoints, and that
...
...
lms/djangoapps/instructor/tests/test_legacy_email.py
View file @
8ee682d4
...
...
@@ -108,3 +108,38 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase):
# Assert that the URL for the email view is not in the response
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertFalse
(
self
.
email_link
in
response
.
content
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
})
def
test_send_mail_unauthorized
(
self
):
""" Test 'Send email' action returns an error if course is not authorized to send email. """
response
=
self
.
client
.
post
(
self
.
url
,
{
'action'
:
'Send email'
,
'to_option'
:
'all'
,
'subject'
:
"Welcome to the course!"
,
'message'
:
"Lets start with an introduction!"
}
)
self
.
assertContains
(
response
,
"Email is not enabled for this course."
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
})
def
test_send_mail_authorized
(
self
):
""" Test 'Send email' action when course is authorized to send email. """
course_authorization
=
CourseAuthorization
(
course_id
=
self
.
course
.
id
,
email_enabled
=
True
)
course_authorization
.
save
()
session
=
self
.
client
.
session
session
[
u'idash_mode:{0}'
.
format
(
self
.
course
.
location
.
course_id
)]
=
'Email'
session
.
save
()
response
=
self
.
client
.
post
(
self
.
url
,
{
'action'
:
'Send email'
,
'to_option'
:
'all'
,
'subject'
:
'Welcome to the course!'
,
'message'
:
'Lets start with an introduction!'
,
}
)
self
.
assertContains
(
response
,
"Your email was successfully queued for sending."
)
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