Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
e1885be2
Commit
e1885be2
authored
Aug 21, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an intermittently failing leaderboard test
parent
7933cae0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
openassessment/xblock/test/test_leaderboard.py
+28
-8
No files found.
openassessment/xblock/test/test_leaderboard.py
View file @
e1885be2
...
@@ -3,19 +3,22 @@
...
@@ -3,19 +3,22 @@
Tests for leaderboard handlers in Open Assessment XBlock.
Tests for leaderboard handlers in Open Assessment XBlock.
"""
"""
import
json
import
json
import
mock
from
django.core.cache
import
cache
from
random
import
randint
from
random
import
randint
from
submissions
import
api
as
sub_api
from
urlparse
import
urlparse
from
.base
import
XBlockHandlerTransactionTestCase
,
scenario
from
django.test.utils
import
override_settings
from
moto
import
mock_s3
import
boto
import
boto
from
boto.s3.key
import
Key
from
boto.s3.key
import
Key
from
openassessment.fileupload
import
api
from
django.test.utils
import
override_settings
from
django.core.cache
import
cache
import
mock
from
moto
import
mock_s3
from
submissions
import
api
as
sub_api
from
.base
import
XBlockHandlerTransactionTestCase
,
scenario
from
openassessment.fileupload
import
api
from
openassessment.xblock.data_conversion
import
create_submission_dict
,
prepare_submission_for_serialization
from
openassessment.xblock.data_conversion
import
create_submission_dict
,
prepare_submission_for_serialization
class
TestLeaderboardRender
(
XBlockHandlerTransactionTestCase
):
class
TestLeaderboardRender
(
XBlockHandlerTransactionTestCase
):
@scenario
(
'data/basic_scenario.xml'
)
@scenario
(
'data/basic_scenario.xml'
)
...
@@ -264,13 +267,19 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
...
@@ -264,13 +267,19 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
"""
"""
if
workflow_status
is
not
None
:
if
workflow_status
is
not
None
:
xblock
.
get_workflow_info
=
mock
.
Mock
(
return_value
=
{
'status'
:
workflow_status
})
xblock
.
get_workflow_info
=
mock
.
Mock
(
return_value
=
{
'status'
:
workflow_status
})
if
workflow_status
==
'done'
:
if
workflow_status
==
'done'
:
path
,
context
=
xblock
.
render_leaderboard_complete
(
xblock
.
get_student_item_dict
())
path
,
context
=
xblock
.
render_leaderboard_complete
(
xblock
.
get_student_item_dict
())
else
:
else
:
path
,
context
=
xblock
.
render_leaderboard_incomplete
()
path
,
context
=
xblock
.
render_leaderboard_incomplete
()
# Strip query string parameters from the file URLs, since these are time-dependent
# (expiration and signature)
if
"topscores"
in
expected_context
:
context
[
"topscores"
]
=
self
.
_clean_score_filenames
(
context
[
"topscores"
])
expected_context
[
"topscores"
]
=
self
.
_clean_score_filenames
(
context
[
"topscores"
])
self
.
assertEqual
(
path
,
expected_path
)
self
.
assertEqual
(
path
,
expected_path
)
self
.
assertEqual
(
context
,
expected_context
)
self
.
assertEqual
(
context
,
expected_context
)
...
@@ -285,3 +294,14 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
...
@@ -285,3 +294,14 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
fragment
=
self
.
runtime
.
render
(
xblock
,
"student_view"
)
fragment
=
self
.
runtime
.
render
(
xblock
,
"student_view"
)
has_leaderboard
=
'openassessment__leaderboard'
in
fragment
.
body_html
()
has_leaderboard
=
'openassessment__leaderboard'
in
fragment
.
body_html
()
self
.
assertEqual
(
has_leaderboard
,
is_visible
)
self
.
assertEqual
(
has_leaderboard
,
is_visible
)
def
_clean_score_filenames
(
self
,
scores
):
"""
Remove querystring parameters from the file name of the score.
"""
for
score
in
scores
:
if
score
.
get
(
"file"
):
url
=
urlparse
(
score
[
"file"
])
score
[
"file"
]
=
url
.
scheme
+
"://"
+
url
.
netloc
+
url
.
path
return
scores
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