Start adding tests for mongo modulestore
* fix up toy course to match current format * fix github sync test that referred to toy course
This commit is contained in:
@@ -1,28 +1,61 @@
|
||||
import pymongo
|
||||
|
||||
from nose.tools import assert_equals, assert_raises, assert_not_equals, with_setup
|
||||
from path import path
|
||||
|
||||
from xmodule.modulestore import Location
|
||||
from xmodule.modulestore.exceptions import InvalidLocationError
|
||||
from xmodule.modulestore.mongo import MongoModuleStore
|
||||
from xmodule.modulestore.xml_importer import import_from_xml
|
||||
|
||||
# from ~/mitx_all/mitx/common/lib/xmodule/xmodule/modulestore/tests/
|
||||
# to ~/mitx_all/mitx/common/test
|
||||
TEST_DIR = path(__file__).abspath().dirname()
|
||||
for i in range(5):
|
||||
TEST_DIR = TEST_DIR.dirname()
|
||||
TEST_DIR = TEST_DIR / 'test'
|
||||
|
||||
DATA_DIR = TEST_DIR / 'data'
|
||||
|
||||
|
||||
host = 'localhost'
|
||||
db = 'xmodule'
|
||||
collection = 'modulestore'
|
||||
fs_root = None # TODO (vshnayder): will need a real fs_root for testing load_item
|
||||
default_class = 'xmodule.raw_module.RawDescriptor'
|
||||
HOST = 'localhost'
|
||||
PORT = 27017
|
||||
DB = 'test'
|
||||
COLLECTION = 'modulestore'
|
||||
FS_ROOT = DATA_DIR # TODO (vshnayder): will need a real fs_root for testing load_item
|
||||
DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor'
|
||||
|
||||
|
||||
connection = None
|
||||
|
||||
def setup():
|
||||
global connection
|
||||
connection = pymongo.connection.Connection(HOST, PORT)
|
||||
|
||||
|
||||
|
||||
def setup_func():
|
||||
# connect to the db
|
||||
global store
|
||||
store = MongoModuleStore(host, db, collection, fs_root, default_class=default_class)
|
||||
store = MongoModuleStore(HOST, DB, COLLECTION, FS_ROOT, default_class=DEFAULT_CLASS)
|
||||
print 'data_dir: {0}'.format(DATA_DIR)
|
||||
import_from_xml(store, DATA_DIR)
|
||||
|
||||
def teardown_func():
|
||||
global store
|
||||
store = None
|
||||
# Destroy the test db.
|
||||
connection.drop_database(DB)
|
||||
|
||||
|
||||
@with_setup(setup_func, teardown_func)
|
||||
def test_init():
|
||||
'''Just make sure the db loads'''
|
||||
pass
|
||||
|
||||
@with_setup(setup_func, teardown_func)
|
||||
def test_get_courses():
|
||||
'''Make sure the course objects loaded properly'''
|
||||
courses = store.get_courses()
|
||||
print courses
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<chapter name="Overview">
|
||||
<video name="Welcome" youtube="0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"/>
|
||||
<videosequence format="Lecture Sequence" name="System Usage Sequence">
|
||||
<html id="Lab2A" filename="Lab2A"/>
|
||||
<html id="toylab" filename="toylab"/>
|
||||
<video name="S0V1: Video Resources" youtube="0.75:EuzkdzfR0i8,1.0:1bK-WdDi6Qw,1.25:0v1VzoDVUTM,1.50:Bxk_-ZJb240"/>
|
||||
</videosequence>
|
||||
</chapter>
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#r1_slider").slider({
|
||||
value: 1, min: 1, max: 10, step: 1, slide: schematic.component_slider,
|
||||
schematic: "ctrls", component: "R1", property: "r", analysis: "dc",
|
||||
})
|
||||
|
||||
$("#r2_slider").slider({
|
||||
value: 1, min: 1, max: 10, step: 1, slide: schematic.component_slider,
|
||||
schematic: "ctrls", component: "R2", property: "r", analysis: "dc",
|
||||
})
|
||||
|
||||
$("#r3_slider").slider({
|
||||
value: 1, min: 1, max: 10, step: 1, slide: schematic.component_slider,
|
||||
schematic: "ctrls", component: "R3", property: "r", analysis: "dc",
|
||||
})
|
||||
|
||||
$("#r4_slider").slider({
|
||||
value: 1, min: 1, max: 10, step: 1, slide: schematic.component_slider,
|
||||
schematic: "ctrls", component: "R4", property: "r", analysis: "dc",
|
||||
})
|
||||
|
||||
$("#slider").slider(); });
|
||||
</script>
|
||||
|
||||
<b>Lab 2A: Superposition Experiment</b>
|
||||
|
||||
<br><br><i>Note: This part of the lab is just to develop your intuition about
|
||||
superposition. There are no responses that need to be checked.</i>
|
||||
|
||||
<br/><br/>Circuits with multiple sources can be hard to analyze as-is. For example, what is the voltage
|
||||
between the two terminals on the right of Figure 1?
|
||||
|
||||
<center>
|
||||
<input width="425" type="hidden" height="150" id="schematic1" parts="" analyses="" class="schematic ctrls" name="test2" value="[["w",[160,64,184,64]],["w",[160,16,184,16]],["w",[64,16,112,16]],["w",[112,64,88,64]],["w",[64,64,88,64]],["g",[88,64,0],{},["0"]],["w",[112,64,160,64]],["w",[16,64,64,64]],["r",[160,16,0],{"name":"R4","r":"1"},["1","0"]],["r",[160,16,1],{"name":"R3","r":"1"},["1","2"]],["i",[112,64,6],{"name":"","value":"6A"},["0","2"]],["r",[64,16,0],{"name":"R2","r":"1"},["2","0"]],["r",[64,16,1],{"name":"R1","r":"1"},["2","3"]],["v",[16,16,0],{"name":"","value":"8V"},["3","0"]],["view",-24,0,2]]"/>
|
||||
Figure 1. Example multi-source circuit
|
||||
</center>
|
||||
|
||||
<br/><br/>We can use superposition to make the analysis much easier.
|
||||
The circuit in Figure 1 can be decomposed into two separate
|
||||
subcircuits: one involving only the voltage source and one involving only the
|
||||
current source. We'll analyze each circuit separately and combine the
|
||||
results using superposition. Recall that to decompose a circuit for
|
||||
analysis, we'll pick each source in turn and set all the other sources
|
||||
to zero (i.e., voltage sources become short circuits and current
|
||||
sources become open circuits). The circuit above has two sources, so
|
||||
the decomposition produces two subcircuits, as shown in Figure 2.
|
||||
|
||||
<center>
|
||||
<table><tr><td>
|
||||
<input style="display:inline;" width="425" type="hidden" height="150" id="schematic2" parts="" analyses="" class="schematic ctrls" name="test2" value="[["w",[160,64,184,64]],["w",[160,16,184,16]],["w",[64,16,112,16]],["w",[112,64,88,64]],["w",[64,64,88,64]],["g",[88,64,0],{},["0"]],["w",[112,64,160,64]],["w",[16,64,64,64]],["r",[160,16,0],{"name":"R4","r":"1"},["1","0"]],["r",[160,16,1],{"name":"R3","r":"1"},["1","2"]],["r",[64,16,0],{"name":"R2","r":"1"},["2","0"]],["r",[64,16,1],{"name":"R1","r":"1"},["2","3"]],["v",[16,16,0],{"name":"","value":"8V"},["3","0"]],["view",-24,0,2]]"/>
|
||||
(a) Subcircuit for analyzing contribution of voltage source
|
||||
</td><td>
|
||||
<input width="425" type="hidden" height="150" id="schematic3" parts="" analyses="" class="schematic ctrls" name="test2" value="[["w",[16,16,16,64]],["w",[160,64,184,64]],["w",[160,16,184,16]],["w",[64,16,112,16]],["w",[112,64,88,64]],["w",[64,64,88,64]],["g",[88,64,0],{},["0"]],["w",[112,64,160,64]],["w",[16,64,64,64]],["r",[160,16,0],{"name":"R4","r":"1"},["1","0"]],["r",[160,16,1],{"name":"R3","r":"1"},["1","2"]],["i",[112,64,6],{"name":"","value":"6A"},["0","2"]],["r",[64,16,0],{"name":"R2","r":"1"},["2","0"]],["r",[64,16,1],{"name":"R1","r":"1"},["2","3"]],["view",-24,0,2]]"/>
|
||||
(b) Subcircuit for analyzing contribution of current source
|
||||
</td></tr></table>
|
||||
<br>Figure 2. Decomposition of Figure 1 into subcircuits
|
||||
</center>
|
||||
|
||||
<br/>Let's use the DC analysis capability of the schematic tool to see superposition
|
||||
in action. The sliders below control the resistances of R1, R2, R3 and R4 in all
|
||||
the diagrams. As you move the sliders, the schematic tool will adjust the appropriate
|
||||
resistance, perform a DC analysis and display the node voltages on the diagrams. Here's
|
||||
what you want to observe as you play with the sliders:
|
||||
|
||||
<ul style="margin-left:2em;margin-top:1em;margin-right:2em;margin-bottom:1em;">
|
||||
<i>The voltage for a node in Figure 1 is the sum of the voltages for
|
||||
that node in Figures 2(a) and 2(b), just as predicted by
|
||||
superposition. (Note that due to round-off in the display of the
|
||||
voltages, the sum of the displayed voltages in Figure 2 may only be within
|
||||
.01 of the voltages displayed in Figure 1.)</i>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<center>
|
||||
<table><tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>R1</td>
|
||||
<td>
|
||||
<div id="r1_slider" style="width:200px; height:10px; margin-left:15px"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>R2</td>
|
||||
<td>
|
||||
<div id="r2_slider" style="width:200px; height:10px; margin-left:15px; margin-top:10px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>R3</td>
|
||||
<td>
|
||||
<div id="r3_slider" style="width:200px; height:10px; margin-left:15px; margin-top:10px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td>R4</td>
|
||||
<td>
|
||||
<div id="r4_slider" style="width:200px; height:10px; margin-left:15px; margin-top:10px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr></table>
|
||||
</center>
|
||||
3
common/test/data/toy/html/toylab.html
Normal file
3
common/test/data/toy/html/toylab.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<b>Lab 2A: Superposition Experiment</b>
|
||||
|
||||
<p>Isn't the toy course great?</p>
|
||||
Reference in New Issue
Block a user