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
28e9ae04
Commit
28e9ae04
authored
Feb 21, 2014
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests of the localized start dates
parent
b21473f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
4 deletions
+62
-4
lms/djangoapps/courseware/tests/test_views.py
+62
-4
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
28e9ae04
...
...
@@ -2,8 +2,9 @@
Tests courseware views.py
"""
import
unittest
from
mock
import
MagicMock
,
patch
from
datetime
import
datetime
from
mock
import
MagicMock
,
patch
from
pytz
import
UTC
from
django.test
import
TestCase
...
...
@@ -30,15 +31,16 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
from
course_modes.models
import
CourseMode
import
shoppingcart
from
util.tests.test_date_utils
import
fake_ugettext
,
fake_pgettext
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
TestJumpTo
(
TestCase
):
"""
Check the jumpto link for a course.
Check the jumpto link for a course.
"""
def
setUp
(
self
):
# Use toy course from XML
self
.
course_name
=
'edX/toy/2012_Fall'
...
...
@@ -71,7 +73,9 @@ class TestJumpTo(TestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
ViewsTestCase
(
TestCase
):
""" Tests for views.py methods. """
"""
Tests for views.py methods.
"""
def
setUp
(
self
):
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
email
=
'test@mit.edu'
)
...
...
@@ -366,3 +370,57 @@ class TestAccordionDueDate(BaseDueDateTests):
return
views
.
render_accordion
(
self
.
request
,
course
,
course
.
get_children
()[
0
]
.
id
,
None
,
None
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
StartDateTests
(
ModuleStoreTestCase
):
"""
Test that start dates are properly localized and displayed on the student
dashboard.
"""
def
setUp
(
self
):
self
.
request_factory
=
RequestFactory
()
self
.
user
=
UserFactory
.
create
()
self
.
request
=
self
.
request_factory
.
get
(
"foo"
)
self
.
request
.
user
=
self
.
user
def
set_up_course
(
self
):
"""
Create a stock course with a specific due date.
:param course_kwargs: All kwargs are passed to through to the :class:`CourseFactory`
"""
course
=
CourseFactory
(
start
=
datetime
(
2013
,
9
,
16
,
7
,
17
,
28
))
course
=
modulestore
()
.
get_instance
(
course
.
id
,
course
.
location
)
# pylint: disable=no-member
return
course
def
get_about_text
(
self
,
course_id
):
"""
Get the text of the /about page for the course.
"""
text
=
views
.
course_about
(
self
.
request
,
course_id
)
.
content
return
text
@patch
(
'util.date_utils.pgettext'
,
fake_pgettext
(
translations
=
{
(
"abbreviated month name"
,
"Sep"
):
"SEPTEMBER"
,
}))
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"
%
Y-
%
b-
%
d"
,
}))
def
test_format_localized_in_studio_course
(
self
):
course
=
self
.
set_up_course
()
text
=
self
.
get_about_text
(
course
.
id
)
# The start date is set in the set_up_course function above.
self
.
assertIn
(
"2013-SEPTEMBER-16"
,
text
)
@patch
(
'util.date_utils.pgettext'
,
fake_pgettext
(
translations
=
{
(
"abbreviated month name"
,
"Jul"
):
"JULY"
,
}))
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"
%
Y-
%
b-
%
d"
,
}))
def
test_format_localized_in_xml_course
(
self
):
text
=
self
.
get_about_text
(
'edX/toy/TT_2012_Fall'
)
# The start date is set in common/test/data/two_toys/policies/TT_2012_Fall/policy.json
self
.
assertIn
(
"2015-JULY-17"
,
text
)
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