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
c8f0e00e
Commit
c8f0e00e
authored
Aug 02, 2016
by
Cliff Dyer
Committed by
GitHub
Aug 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12848 from eduNEXT/juancamilom/TNL-4204
a first contribution to fix TNL-4204 byte sized bug
parents
b406a70f
b1f748b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
2 deletions
+67
-2
common/lib/xmodule/xmodule/html_module.py
+4
-2
common/lib/xmodule/xmodule/tests/test_html_module.py
+63
-0
No files found.
common/lib/xmodule/xmodule/html_module.py
View file @
c8f0e00e
...
...
@@ -440,8 +440,10 @@ class CourseInfoModule(CourseInfoFields, HtmlModuleMixin):
return
self
.
data
else
:
course_updates
=
[
item
for
item
in
self
.
items
if
item
.
get
(
'status'
)
==
self
.
STATUS_VISIBLE
]
course_updates
.
sort
(
key
=
lambda
item
:
CourseInfoModule
.
safe_parse_date
(
item
[
'date'
]),
reverse
=
True
)
course_updates
.
sort
(
key
=
lambda
item
:
(
CourseInfoModule
.
safe_parse_date
(
item
[
'date'
]),
item
[
'id'
]),
reverse
=
True
)
context
=
{
'visible_updates'
:
course_updates
[:
3
],
'hidden_updates'
:
course_updates
[
3
:],
...
...
common/lib/xmodule/xmodule/tests/test_html_module.py
View file @
c8f0e00e
...
...
@@ -181,3 +181,66 @@ class CourseInfoModuleTestCase(unittest.TestCase):
info_module
.
get_html
()
except
ValueError
:
self
.
fail
(
"CourseInfoModule could not parse an invalid date!"
)
def
test_updates_order
(
self
):
"""
Tests that a course info module will render its updates in the correct order.
"""
sample_update_data
=
[
{
"id"
:
3
,
"date"
:
"March 18, 1982"
,
"content"
:
"This is a very important update that was inserted last with an older date!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
},
{
"id"
:
1
,
"date"
:
"January 1, 2012"
,
"content"
:
"This is a very important update that was inserted first!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
},
{
"id"
:
2
,
"date"
:
"January 1, 2012"
,
"content"
:
"This is a very important update that was inserted second!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
}
]
info_module
=
CourseInfoModule
(
Mock
(),
Mock
(),
DictFieldData
({
'items'
:
sample_update_data
,
'data'
:
""
}),
Mock
()
)
# This is the expected context that should be used by the render function
expected_context
=
{
'visible_updates'
:
[
{
"id"
:
2
,
"date"
:
"January 1, 2012"
,
"content"
:
"This is a very important update that was inserted second!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
},
{
"id"
:
1
,
"date"
:
"January 1, 2012"
,
"content"
:
"This is a very important update that was inserted first!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
},
{
"id"
:
3
,
"date"
:
"March 18, 1982"
,
"content"
:
"This is a very important update that was inserted last with an older date!"
,
"status"
:
CourseInfoModule
.
STATUS_VISIBLE
,
}
],
'hidden_updates'
:
[],
}
template_name
=
"{0}/course_updates.html"
.
format
(
info_module
.
TEMPLATE_DIR
)
info_module
.
get_html
()
# Assertion to validate that render function is called with the expected context
info_module
.
system
.
render_template
.
assert_called_once_with
(
template_name
,
expected_context
)
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