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
8323cc7c
Commit
8323cc7c
authored
May 09, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests
parent
7b8b168f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
76 deletions
+48
-76
common/lib/xmodule/xmodule/tests/dummy_system.py
+0
-55
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+0
-0
common/lib/xmodule/xmodule/tests/test_peer_grading.py
+18
-19
common/lib/xmodule/xmodule/tests/test_util_open_ended.py
+27
-2
common/test/data/open_ended/course/2012_Fall.xml
+1
-0
common/test/data/open_ended/peergrading/PeerGradingScored.xml
+2
-0
No files found.
common/lib/xmodule/xmodule/tests/dummy_system.py
deleted
100644 → 0
View file @
7b8b168f
from
.
import
test_system
import
unittest
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.xml
import
ImportSystem
,
XMLModuleStore
from
xmodule.tests.test_export
import
DATA_DIR
from
fs.memoryfs
import
MemoryFS
from
mock
import
patch
,
Mock
class
DummySystem
(
ImportSystem
):
@patch
(
'xmodule.modulestore.xml.OSFS'
,
lambda
dir
:
MemoryFS
())
def
__init__
(
self
,
load_error_modules
,
org
,
course
):
xmlstore
=
XMLModuleStore
(
"data_dir"
,
course_dirs
=
[],
load_error_modules
=
load_error_modules
)
course_id
=
"/"
.
join
([
org
,
course
,
'test_run'
])
course_dir
=
"test_dir"
policy
=
{}
error_tracker
=
Mock
()
parent_tracker
=
Mock
()
super
(
DummySystem
,
self
)
.
__init__
(
xmlstore
,
course_id
,
course_dir
,
policy
,
error_tracker
,
parent_tracker
,
load_error_modules
=
load_error_modules
,
)
def
render_template
(
self
,
template
,
context
):
raise
Exception
(
"Shouldn't be called"
)
class
DummySystemUser
(
object
):
test_system
=
test_system
()
@staticmethod
def
get_import_system
(
org
,
course
,
load_error_modules
=
True
):
'''Get a dummy system'''
return
DummySystem
(
load_error_modules
,
org
,
course
)
def
get_course
(
self
,
name
):
"""Get a test course by directory name. If there's more than one, error."""
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
name
])
courses
=
modulestore
.
get_courses
()
self
.
modulestore
=
modulestore
return
courses
[
0
]
def
get_module_from_location
(
self
,
location
,
course
):
course
=
self
.
get_course
(
course
)
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
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
8323cc7c
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/tests/test_peer_grading.py
View file @
8323cc7c
import
unittest
from
xmodule.modulestore
import
Location
import
json
from
lxml
import
etree
from
mock
import
Mock
from
.
import
test_system
from
dummy_system
import
DummySystem
,
DummySystemUser
from
test_util_open_ended
import
MockQueryDict
from
.
import
test_system
from
test_util_open_ended
import
MockQueryDict
,
DummyModulestore
from
xmodule.peer_grading_module
import
PeerGradingModule
,
PeerGradingDescriptor
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingServiceError
import
logging
log
=
logging
.
getLogger
(
__name__
)
ORG
=
"edX"
COURSE
=
"open_ended"
COURSE
=
"open_ended"
class
PeerGradingModuleTest
(
unittest
.
TestCase
,
Dummy
SystemUser
):
class
PeerGradingModuleTest
(
unittest
.
TestCase
,
Dummy
Modulestore
):
problem_location
=
Location
([
"i4x"
,
"edX"
,
"open_ended"
,
"peergrading"
,
"PeerGradingSample"
])
calibrated_dict
=
{
'location'
:
"blah"
}
"PeerGradingSample"
])
calibrated_dict
=
{
'location'
:
"blah"
}
save_dict
=
MockQueryDict
()
save_dict
.
update
({
'location'
:
"blah"
,
'submission_id'
:
1
,
'submission_key'
:
""
,
'location'
:
"blah"
,
'submission_id'
:
1
,
'submission_key'
:
""
,
'score'
:
1
,
'feedback'
:
""
,
'rubric_scores[]'
:
[
0
,
1
],
'feedback'
:
""
,
'rubric_scores[]'
:
[
0
,
1
],
'submission_flagged'
:
False
,
})
})
def
setUp
(
self
):
self
.
test_system
=
test_system
()
...
...
@@ -54,17 +54,16 @@ class PeerGradingModuleTest(unittest.TestCase, DummySystemUser):
max_score
=
self
.
peer_grading
.
max_score
()
def
get_next_submission
(
self
):
success
,
next_submission
=
self
.
peer_grading
.
get_next_submission
({
'location'
:
'blah'
})
success
,
next_submission
=
self
.
peer_grading
.
get_next_submission
({
'location'
:
'blah'
})
def
test_save_grade
(
self
):
self
.
peer_grading
.
save_grade
(
self
.
save_dict
)
def
test_is_student_calibrated
(
self
):
calibrated_dict
=
{
'location'
:
"blah"
}
calibrated_dict
=
{
'location'
:
"blah"
}
self
.
peer_grading
.
is_student_calibrated
(
self
.
calibrated_dict
)
def
test_show_calibration_essay
(
self
):
self
.
peer_grading
.
show_calibration_essay
(
self
.
calibrated_dict
)
def
test_save_calibration_essay
(
self
):
...
...
common/lib/xmodule/xmodule/tests/test_util_open_ended.py
View file @
8323cc7c
from
.
import
test_system
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.xml
import
ImportSystem
,
XMLModuleStore
from
xmodule.tests.test_export
import
DATA_DIR
OPEN_ENDED_GRADING_INTERFACE
=
{
'url'
:
'blah/'
,
'username'
:
'incorrect'
,
...
...
@@ -17,10 +22,30 @@ 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
return
default
class
DummyModulestore
(
object
):
test_system
=
test_system
()
def
get_course
(
self
,
name
):
"""Get a test course by directory name. If there's more than one, error."""
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
name
])
courses
=
modulestore
.
get_courses
()
self
.
modulestore
=
modulestore
return
courses
[
0
]
def
get_module_from_location
(
self
,
location
,
course
):
course
=
self
.
get_course
(
course
)
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
common/test/data/open_ended/course/2012_Fall.xml
View file @
8323cc7c
...
...
@@ -2,5 +2,6 @@
<chapter
url_name=
"Overview"
>
<combinedopenended
url_name=
"SampleQuestion"
/>
<peergrading
url_name=
"PeerGradingSample"
/>
<peergrading
url_name=
"PeerGradingScored"
/>
</chapter>
</course>
common/test/data/open_ended/peergrading/PeerGradingScored.xml
0 → 100644
View file @
8323cc7c
<peergrading
is_graded=
"True"
max_grade=
"1"
use_for_single_location=
"True"
link_to_location=
"i4x://edX/open_ended/combinedopenended/SampleQuestion"
/>
\ No newline at end of file
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