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
fd46ebd1
Commit
fd46ebd1
authored
May 08, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move some functions, make notification tests more robust
parent
ff84545f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
42 deletions
+58
-42
common/lib/xmodule/xmodule/tests/dummy_system.py
+14
-3
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+3
-22
common/lib/xmodule/xmodule/tests/test_peer_grading.py
+3
-7
common/test/data/open_ended/course.xml
+1
-1
lms/djangoapps/open_ended_grading/tests.py
+37
-9
No files found.
common/lib/xmodule/xmodule/tests/dummy_system.py
View file @
fd46ebd1
...
...
@@ -44,7 +44,6 @@ class DummySystemUser(object):
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
name
])
courses
=
modulestore
.
get_courses
()
self
.
modulestore
=
modulestore
self
.
assertEquals
(
len
(
courses
),
1
)
return
courses
[
0
]
def
get_module_from_location
(
self
,
location
,
course
):
...
...
@@ -52,4 +51,16 @@ class DummySystemUser(object):
if
not
isinstance
(
location
,
Location
):
location
=
Location
(
location
)
descriptor
=
self
.
modulestore
.
get_instance
(
course
.
id
,
location
,
depth
=
None
)
return
descriptor
.
xmodule
(
self
.
test_system
)
\ No newline at end of file
return
descriptor
.
xmodule
(
self
.
test_system
)
class
MockQueryDict
(
dict
):
"""
Mock a query set so that it can be used with default authorization
"""
def
getlist
(
self
,
key
,
default
=
None
):
try
:
return
super
(
MockQueryDict
,
self
)
.
__getitem__
(
key
)
except
KeyError
:
if
default
is
None
:
return
[]
return
default
\ No newline at end of file
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
fd46ebd1
...
...
@@ -2,21 +2,14 @@ import json
from
mock
import
Mock
,
MagicMock
,
ANY
import
unittest
from
fs.memoryfs
import
MemoryFS
from
mock
import
patch
from
dummy_system
import
DummySystemUser
from
dummy_system
import
DummySystemUser
,
MockQueryDict
from
xmodule.open_ended_grading_classes.openendedchild
import
OpenEndedChild
from
xmodule.open_ended_grading_classes.open_ended_module
import
OpenEndedModule
from
xmodule.open_ended_grading_classes.combined_open_ended_modulev1
import
CombinedOpenEndedV1Module
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingServiceError
from
xmodule.combined_open_ended_module
import
CombinedOpenEndedModule
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.xml
import
ImportSystem
,
XMLModuleStore
from
xmodule.tests.test_export
import
DATA_DIR
from
lxml
import
etree
import
capa.xqueue_interface
as
xqueue_interface
...
...
@@ -27,23 +20,11 @@ log = logging.getLogger(__name__)
from
.
import
test_system
ORG
=
'
test_org
'
ORG
=
'
edX
'
COURSE
=
'open_ended'
# name of directory with course data
import
test_util_open_ended
class
MockQueryDict
(
dict
):
"""
Mock a query set so that it can be used with default authorization
"""
def
getlist
(
self
,
key
,
default
=
None
):
try
:
return
super
(
MockQueryDict
,
self
)
.
__getitem__
(
key
)
except
KeyError
:
if
default
is
None
:
return
[]
return
default
"""
Tests for the various pieces of the CombinedOpenEndedGrading system
...
...
@@ -492,7 +473,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
self
.
assertEqual
(
score_dict
[
'total'
],
15.0
)
class
OpenEndedModuleXmlTest
(
unittest
.
TestCase
,
DummySystemUser
):
problem_location
=
Location
([
"i4x"
,
"edX"
,
"o
e_test
"
,
"combinedopenended"
,
"SampleQuestion"
])
problem_location
=
Location
([
"i4x"
,
"edX"
,
"o
pen_ended
"
,
"combinedopenended"
,
"SampleQuestion"
])
answer
=
"blah blah"
assessment
=
[
0
,
1
]
hint
=
"blah"
...
...
common/lib/xmodule/xmodule/tests/test_peer_grading.py
View file @
fd46ebd1
...
...
@@ -14,17 +14,13 @@ COURSE="open_ended"
class
PeerGradingModuleTest
(
unittest
.
TestCase
,
DummySystemUser
):
location
=
Location
([
"i4x"
,
"edX"
,
"open_ended"
,
"peergrading"
,
"SampleQuestion"
])
max_score
=
1
definition
=
"<peergrading/>"
descriptor
=
Mock
(
data
=
definition
)
problem_location
=
Location
([
"i4x"
,
"edX"
,
"open_ended"
,
"peergrading"
,
"PeerGradingSample"
])
def
setUp
(
self
):
self
.
test_system
=
test_system
()
self
.
test_system
.
open_ended_grading_interface
=
None
self
.
peer_grading
=
PeerGradingModule
(
self
.
test_system
,
self
.
location
,
self
.
descriptor
,
model_data
=
{
'data'
:
self
.
definition
}
)
self
.
peer_grading
=
self
.
get_module_from_location
(
self
.
problem_location
,
COURSE
)
def
test_module_closed
(
self
):
closed
=
self
.
peer_grading
.
closed
()
...
...
common/test/data/open_ended/course.xml
View file @
fd46ebd1
<course
org=
"edX"
course=
"o
e_test
"
url_name=
"2012_Fall"
/>
<course
org=
"edX"
course=
"o
pen_ended
"
url_name=
"2012_Fall"
/>
lms/djangoapps/open_ended_grading/tests.py
View file @
fd46ebd1
...
...
@@ -84,7 +84,13 @@ class TestStaffGradingService(LoginEnrollmentTestCase):
data
=
{
'location'
:
self
.
location
}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
r
.
content
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
])
self
.
assertEquals
(
d
[
'submission_id'
],
self
.
mock_service
.
cnt
)
self
.
assertIsNotNone
(
d
[
'submission'
])
...
...
@@ -112,7 +118,11 @@ class TestStaffGradingService(LoginEnrollmentTestCase):
data
.
update
({
'skipped'
:
True
})
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
r
.
content
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
],
str
(
d
))
self
.
assertEquals
(
d
[
'submission_id'
],
self
.
mock_service
.
cnt
)
...
...
@@ -129,7 +139,11 @@ class TestStaffGradingService(LoginEnrollmentTestCase):
data
=
{}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
r
.
content
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
],
str
(
d
))
self
.
assertIsNotNone
(
d
[
'problem_list'
])
...
...
@@ -179,7 +193,11 @@ class TestPeerGradingService(LoginEnrollmentTestCase):
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
get_next_submission
(
data
)
d
=
json
.
loads
(
r
)
d
=
r
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
...
...
@@ -213,7 +231,11 @@ class TestPeerGradingService(LoginEnrollmentTestCase):
qdict
.
keys
=
data
.
keys
r
=
self
.
peer_module
.
save_grade
(
qdict
)
d
=
json
.
loads
(
r
)
d
=
r
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
])
def
test_save_grade_missing_keys
(
self
):
...
...
@@ -225,7 +247,11 @@ class TestPeerGradingService(LoginEnrollmentTestCase):
def
test_is_calibrated_success
(
self
):
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
is_student_calibrated
(
data
)
d
=
json
.
loads
(
r
)
d
=
r
try
:
d
=
json
.
loads
(
d
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
'calibrated'
in
d
)
...
...
@@ -239,9 +265,11 @@ class TestPeerGradingService(LoginEnrollmentTestCase):
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
show_calibration_essay
(
data
)
d
=
json
.
loads
(
r
)
log
.
debug
(
d
)
log
.
debug
(
type
(
d
))
d
=
r
try
:
d
=
json
.
loads
(
r
)
except
Exception
:
pass
self
.
assertTrue
(
d
[
'success'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
...
...
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