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
e41172d5
Commit
e41172d5
authored
Jan 20, 2013
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add start of test framework for capa
parent
bc1452f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
common/lib/xmodule/xmodule/tests/test_capa_module.py
+60
-0
No files found.
common/lib/xmodule/xmodule/tests/test_capa_module.py
0 → 100644
View file @
e41172d5
import
json
from
mock
import
Mock
import
unittest
from
xmodule.capa_module
import
CapaModule
from
xmodule.modulestore
import
Location
from
lxml
import
etree
from
.
import
test_system
class
CapaFactory
(
object
):
"""
A helper class to create problem modules with various parameters for testing.
"""
sample_problem_xml
=
"""<?xml version="1.0"?>
<problem>
<text>
<p>What is pi, to two decimal placs?</p>
</text>
<numericalresponse answer="3.14">
<textline math="1" size="30"/>
</numericalresponse>
</problem>
"""
num
=
0
@staticmethod
def
next_num
():
CapaFactory
.
num
+=
1
return
CapaFactory
.
num
@staticmethod
def
create
():
definition
=
{
'data'
:
CapaFactory
.
sample_problem_xml
,}
location
=
Location
([
"i4x"
,
"edX"
,
"capa_test"
,
"problem"
,
"SampleProblem{0}"
.
format
(
CapaFactory
.
next_num
())])
metadata
=
{}
descriptor
=
Mock
(
weight
=
"1"
)
instance_state
=
None
module
=
CapaModule
(
test_system
,
location
,
definition
,
descriptor
,
instance_state
,
None
,
metadata
=
metadata
)
return
module
class
CapaModuleTest
(
unittest
.
TestCase
):
def
test_import
(
self
):
module
=
CapaFactory
.
create
()
self
.
assertEqual
(
module
.
get_score
()[
'score'
],
0
)
other_module
=
CapaFactory
.
create
()
self
.
assertEqual
(
module
.
get_score
()[
'score'
],
0
)
self
.
assertNotEqual
(
module
.
url_name
,
other_module
.
url_name
,
"Factory should be creating unique names for each problem"
)
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