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
1ad643ac
Commit
1ad643ac
authored
May 19, 2017
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow sending emails to course modes even if they've expired (EDUCATOR-364)
parent
73c41388
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
lms/djangoapps/bulk_email/models.py
+1
-1
lms/djangoapps/bulk_email/tests/test_models.py
+30
-14
No files found.
lms/djangoapps/bulk_email/models.py
View file @
1ad643ac
...
@@ -217,7 +217,7 @@ class CourseModeTarget(Target):
...
@@ -217,7 +217,7 @@ class CourseModeTarget(Target):
if
mode_slug
is
None
:
if
mode_slug
is
None
:
raise
ValueError
(
"Cannot create a CourseModeTarget without specifying a mode_slug."
)
raise
ValueError
(
"Cannot create a CourseModeTarget without specifying a mode_slug."
)
try
:
try
:
validate_course_mode
(
unicode
(
course_id
),
mode_slug
)
validate_course_mode
(
unicode
(
course_id
),
mode_slug
,
include_expired
=
True
)
except
CourseModeNotFoundError
:
except
CourseModeNotFoundError
:
raise
ValueError
(
raise
ValueError
(
"Track {track} does not exist in course {course_id}"
.
format
(
"Track {track} does not exist in course {course_id}"
.
format
(
...
...
lms/djangoapps/bulk_email/tests/test_models.py
View file @
1ad643ac
"""
"""
Unit tests for bulk-email-related models.
Unit tests for bulk-email-related models.
"""
"""
from
django.test
import
TestCase
import
datetime
from
django.core.management
import
call_command
from
student.tests.factories
import
UserFactory
from
mock
import
patch
,
Mock
from
nose.plugins.attrib
import
attr
import
ddt
from
bulk_email.models
import
(
from
bulk_email.models
import
(
CourseEmail
,
CourseEmail
,
SEND_TO_COHORT
,
SEND_TO_COHORT
,
...
@@ -19,13 +14,22 @@ from bulk_email.models import (
...
@@ -19,13 +14,22 @@ from bulk_email.models import (
BulkEmailFlag
BulkEmailFlag
)
)
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
from
openedx.core.djangoapps.course_groups.models
import
CourseCohort
from
django.core.management
import
call_command
from
django.test
import
TestCase
from
mock
import
patch
,
Mock
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
openedx.core.djangoapps.course_groups.models
import
CourseCohort
@ddt.ddt
@attr
(
shard
=
1
)
@attr
(
shard
=
1
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
CourseEmailTest
(
TestCase
):
class
CourseEmailTest
(
ModuleStore
TestCase
):
"""Test the CourseEmail model."""
"""Test the CourseEmail model."""
def
test_creation
(
self
):
def
test_creation
(
self
):
...
@@ -69,15 +73,27 @@ class CourseEmailTest(TestCase):
...
@@ -69,15 +73,27 @@ class CourseEmailTest(TestCase):
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
CourseEmail
.
create
(
course_id
,
sender
,
to_option
,
subject
,
html_message
)
CourseEmail
.
create
(
course_id
,
sender
,
to_option
,
subject
,
html_message
)
def
test_track_target
(
self
):
@ddt.data
(
course_id
=
CourseKey
.
from_string
(
'abc/123/doremi'
)
datetime
.
datetime
(
1999
,
1
,
1
),
datetime
.
datetime
(
datetime
.
MAXYEAR
,
1
,
1
),
)
def
test_track_target
(
self
,
expiration_datetime
):
"""
Tests that emails can be sent to a specific track. Also checks that
emails can be sent to an expired track (EDUCATOR-364)
"""
course
=
CourseFactory
.
create
()
course_id
=
course
.
id
sender
=
UserFactory
.
create
()
sender
=
UserFactory
.
create
()
to_option
=
'track:test'
to_option
=
'track:test'
subject
=
"dummy subject"
subject
=
"dummy subject"
html_message
=
"<html>dummy message</html>"
html_message
=
"<html>dummy message</html>"
CourseMode
.
objects
.
create
(
mode_slug
=
'test'
,
mode_display_name
=
'Test'
,
course_id
=
course_id
)
CourseMode
.
objects
.
create
(
with
patch
(
'bulk_email.models.validate_course_mode'
):
mode_slug
=
'test'
,
# we don't have a real course, so validation will fail. Mock it out!
mode_display_name
=
'Test'
,
course_id
=
course_id
,
expiration_datetime
=
expiration_datetime
,
)
email
=
CourseEmail
.
create
(
course_id
,
sender
,
[
to_option
],
subject
,
html_message
)
email
=
CourseEmail
.
create
(
course_id
,
sender
,
[
to_option
],
subject
,
html_message
)
self
.
assertEqual
(
len
(
email
.
targets
.
all
()),
1
)
self
.
assertEqual
(
len
(
email
.
targets
.
all
()),
1
)
target
=
email
.
targets
.
all
()[
0
]
target
=
email
.
targets
.
all
()[
0
]
...
...
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