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
20946e5f
Commit
20946e5f
authored
Feb 03, 2014
by
Stephen Sanchez
Committed by
Joe Blaylock
Feb 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a few tests for the Open Assessment XBlock
parent
29e81624
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
2 deletions
+90
-2
AUTHORS
+3
-1
apps/openassessment/xblock/test/test_openassessment.py
+86
-0
settings/test.py
+1
-1
No files found.
AUTHORS
View file @
20946e5f
Stephen Sanchez <steve@edx.org>
Joe Blaylock <jrbl@stanford.edu>
Joe Blaylock <jrbl@stanford.edu>
Will Daly <will@edx.org>
Will Daly <will@edx.org>
David Ormsbee <dormsbee@edx.org>
Stephen Sanchez <steve@edx.org>
\ No newline at end of file
apps/openassessment/xblock/test/test_openassessment.py
0 → 100644
View file @
20946e5f
"""
Tests the Open Assessment XBlock functionality.
"""
import
json
import
webob
from
django.test
import
TestCase
from
mock
import
patch
from
workbench.runtime
import
WorkbenchRuntime
from
submissions
import
api
from
submissions.api
import
SubmissionInternalError
class
TestOpenAssessment
(
TestCase
):
runtime
=
None
assessment
=
None
def
setUp
(
self
):
self
.
runtime
=
WorkbenchRuntime
()
self
.
runtime
.
user_id
=
"Bob"
assessment_id
=
self
.
runtime
.
parse_xml_string
(
"""<openassessment
prompt="This is my prompt. There are many like it, but this one is mine."
course_id="RopesCourse"
/>
"""
,
self
.
runtime
.
id_generator
)
self
.
assessment
=
self
.
runtime
.
get_block
(
assessment_id
)
def
make_request
(
self
,
body
):
"""Mock request method."""
request
=
webob
.
Request
({})
request
.
body
=
body
return
request
def
text_of_response
(
self
,
response
):
"""Return the text of response."""
return
""
.
join
(
response
.
app_iter
)
def
test_submit_submission
(
self
):
"""
Verify we can submit an answer to the XBlock and get the expected return
value.
"""
json_data
=
json
.
dumps
(
{
"submission"
:
"This is my answer to this test question!"
}
)
resp
=
self
.
runtime
.
handle
(
self
.
assessment
,
'submit'
,
self
.
make_request
(
json_data
)
)
result
=
self
.
text_of_response
(
resp
)
self
.
assertEqual
(
"true"
,
result
)
@patch.object
(
api
,
'create_submission'
)
def
test_submission_failure
(
self
,
mock_submit
):
"""
Nothing from the front end currently causes an exception. However the
backend could have an internal error that will bubble up. This will
mock an internal error and ensure the front end returns the proper
value.
"""
mock_submit
.
side_effect
=
SubmissionInternalError
(
"Cat on fire."
)
json_data
=
json
.
dumps
(
{
"submission"
:
"This is my answer to this test question!"
}
)
resp
=
self
.
runtime
.
handle
(
self
.
assessment
,
'submit'
,
self
.
make_request
(
json_data
)
)
result
=
self
.
text_of_response
(
resp
)
self
.
assertEquals
(
"false"
,
result
)
def
test_load_student_view
(
self
):
"""
View basic test for verifying we're returned some HTML about the
Open Assessment XBlock. We don't want to match too heavily against the
contents.
"""
xblock_fragment
=
self
.
runtime
.
render
(
self
.
assessment
,
"student_view"
)
self
.
assertTrue
(
xblock_fragment
.
body_html
()
.
find
(
"Openassessmentblock"
))
settings/test.py
View file @
20946e5f
...
@@ -5,7 +5,7 @@ Test-specific Django settings.
...
@@ -5,7 +5,7 @@ Test-specific Django settings.
# Inherit from base settings
# Inherit from base settings
from
.base
import
*
from
.base
import
*
TEST_APPS
=
(
'openassessment.peer'
,
'submissions'
,)
TEST_APPS
=
(
'openassessment.peer'
,
'submissions'
,
"openassessment.xblock"
)
# Configure nose
# Configure nose
NOSE_ARGS
=
[
NOSE_ARGS
=
[
...
...
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