Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
27 changes: 1 addition & 26 deletions runTests.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
#!/usr/bin/env bash

set -e
testhome=`pwd`
port=8081
for t in 'activecode' 'assess' 'clickableArea' 'dragndrop' 'fitb' 'poll' 'question' 'reveal' 'shortanswer' 'tabbedStuff'; do
cd runestone/$t/test
runestone build --all
runestone serve --port $port &
SERVE_PID=$!
echo "Running test_${t}.py" $port
set -x
python "test_${t}.py"
if [ $? -ne 0 ]; then
echo "Test failed"
pgrep -lf '.*runestone serve.*' | awk '{ print $1 }' | xargs kill
exit 1
else
echo "killing server" $SERVE_PID
kill $SERVE_PID
fi
set -e
cd $testhome
#port=$((port+1))
done

exit 0
python -m unittest discover
3 changes: 1 addition & 2 deletions runestone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def runestone_static_dirs():
module_static_js = ['%s/js' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/js' % os.path.join(basedir,x))]
module_static_css = ['%s/css' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/css' % os.path.join(basedir,x))]
module_static_image = ['%s/images' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/images' % os.path.join(basedir,x))]
module_static_bootstrap = ['%s/bootstrap' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/bootstrap' % os.path.join(basedir,x))]
module_static_bootstrap = ['%s/bootstrap' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/bootstrap' % os.path.join(basedir,x))]

return module_static_js + module_static_css + module_static_image + module_static_bootstrap

Expand Down Expand Up @@ -102,7 +102,6 @@ def build(options):
cmap = {'activecode': ActiveCode,
'mchoice': MChoice,
'fillintheblank': FillInTheBlank,
'blank': Blank,
'timed': TimedDirective,
'qnum': QuestionNumber,
'codelens': Codelens,
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions runestone/activecode/test/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# `rst_prolog <http://www.sphinx-doc.org/en/stable/config.html#confval-rst_prolog>`_:
# A string of reStructuredText that will be included at the beginning of every
# source file that is read.
rst_prolog = (
# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
"""

.. |blank| replace:: :blank:`x`
"""
)

# -- Options for HTML output ---------------------------------------------------

Expand Down
25 changes: 3 additions & 22 deletions runestone/activecode/test/test_activecode.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.common.exceptions import WebDriverException
import unittest
import sys
from ...unittest_base import module_fixture_maker, RunestoneTestCase

PORT = '8081'

class ActiveCodeTests(unittest.TestCase):
def setUp(self):
#self.driver = webdriver.Firefox() # good for development
self.driver = webdriver.PhantomJS() # use this for Jenkins auto testing
self.host = 'http://127.0.0.1:' + PORT
setUpModule, tearDownModule = module_fixture_maker(__file__)

class ActiveCodeTests(RunestoneTestCase):
def test_hello(self):
'''
1. Get the outer div id of the activecode component
Expand Down Expand Up @@ -58,13 +49,3 @@ def test_history(self):
rb.click()
output = t1.find_element_by_class_name("ac_output")
self.assertEqual(output.text.strip(), "Hello World")

def tearDown(self):
self.driver.quit()



if __name__ == '__main__':
if len(sys.argv) > 1:
PORT = sys.argv.pop()
unittest.main()
1 change: 0 additions & 1 deletion runestone/assess/multiplechoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def run(self):
# .. code-block::
# :number-lines:
#
#
# mcNode = MChoiceNode()
# Item 1 of problem text
# ...
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions runestone/assess/test/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# `rst_prolog <http://www.sphinx-doc.org/en/stable/config.html#confval-rst_prolog>`_:
# A string of reStructuredText that will be included at the beginning of every
# source file that is read.
rst_prolog = (
# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
"""

.. |blank| replace:: :blank:`x`
"""
)


# -- Options for HTML output ---------------------------------------------------

Expand Down
27 changes: 4 additions & 23 deletions runestone/assess/test/test_assess.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@

__author__ = 'yasinovskyy'

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.common.exceptions import WebDriverException
import unittest
import sys
from ...unittest_base import module_fixture_maker, RunestoneTestCase

PORT = '8081'

class MultipleChoiceQuestion_Tests(unittest.TestCase):
def setUp(self):
#self.driver = webdriver.Firefox() # good for development
self.driver = webdriver.PhantomJS() # use this for Jenkins auto testing
self.host = 'http://127.0.0.1:' + PORT
setUpModule, tearDownModule = module_fixture_maker(__file__)

class MultipleChoiceQuestion_Tests(RunestoneTestCase):
def test_ma1(self):
'''Multiple Answer: Nothing selected, Check button clicked'''
self.driver.get(self.host + "/index.html")
Expand Down Expand Up @@ -130,7 +121,7 @@ def test_mc3(self):
'''Multiple Choice: Incorrect answer selected'''
self.driver.get(self.host + "/index.html")
t1 = self.driver.find_element_by_id("question2")

t1.find_element_by_id("question2_opt_1").click()

btn_check = t1.find_element_by_tag_name('button')
Expand Down Expand Up @@ -161,13 +152,3 @@ def test_mc4(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def tearDown(self):
self.driver.quit()


if __name__ == '__main__':
if len(sys.argv) > 1:
PORT = sys.argv.pop()
unittest.main(verbosity=2)
Empty file.
11 changes: 11 additions & 0 deletions runestone/clickableArea/test/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# `rst_prolog <http://www.sphinx-doc.org/en/stable/config.html#confval-rst_prolog>`_:
# A string of reStructuredText that will be included at the beginning of every
# source file that is read.
rst_prolog = (
# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
"""

.. |blank| replace:: :blank:`x`
"""
)


# -- Options for HTML output ---------------------------------------------------

Expand Down
48 changes: 14 additions & 34 deletions runestone/clickableArea/test/test_clickableArea.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@

__author__ = 'yasinovskyy'

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.common.exceptions import WebDriverException
import unittest
import sys
from ...unittest_base import module_fixture_maker, RunestoneTestCase

PORT = '8081'
setUpModule, tearDownModule = module_fixture_maker(__file__)
ANSWERS = ["Red Orange Yellow", "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"]

class ClickableAreaQuestion_Tests(unittest.TestCase):
def setUp(self):
#self.driver = webdriver.Firefox() # good for development
self.driver = webdriver.PhantomJS() # use this for Jenkins auto testing
self.host = 'http://127.0.0.1:' + PORT


class ClickableAreaQuestion_Tests(RunestoneTestCase):
def test_ca1(self):
'''Text/Code: Nothing selected'''
self.driver.get(self.host + "/index.html")
Expand All @@ -33,7 +23,7 @@ def test_ca1(self):
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca2(self):
'''Text/Code: Correct answer(s) selected'''
self.driver.get(self.host + "/index.html")
Expand All @@ -56,8 +46,8 @@ def test_ca2(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-success", cnamestr)


def test_ca3(self):
'''Text/Code: Incorrect answer selected'''
self.driver.get(self.host + "/index.html")
Expand All @@ -81,7 +71,7 @@ def test_ca3(self):
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca4(self):
'''Text/Code: All options clicked one by one'''
self.driver.get(self.host + "/index.html")
Expand All @@ -106,7 +96,7 @@ def test_ca4(self):
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca5(self):
'''Text/Code: Correct answer selected and unselected'''
self.driver.get(self.host + "/index.html")
Expand All @@ -122,7 +112,7 @@ def test_ca5(self):
if target.text in ANSWERS:
cnamestr = target.get_attribute("class")
self.assertNotIn("clickable-clicked", cnamestr)


def test_ca6(self):
'''Table: Nothing selected'''
Expand All @@ -136,8 +126,8 @@ def test_ca6(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca7(self):
'''Table: Correct answer(s) selected'''
self.driver.get(self.host + "/index.html")
Expand All @@ -160,7 +150,7 @@ def test_ca7(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-success", cnamestr)


def test_ca8(self):
'''Table: Incorrect answer selected'''
Expand All @@ -184,7 +174,7 @@ def test_ca8(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca9(self):
'''Table: All options clicked one by one'''
Expand All @@ -209,7 +199,7 @@ def test_ca9(self):
self.assertIsNotNone(fb)
cnamestr = fb.get_attribute("class")
self.assertIn("alert-danger", cnamestr)


def test_ca10(self):
'''Table: Correct answer selected and unselected'''
Expand All @@ -226,13 +216,3 @@ def test_ca10(self):
if target.text in ANSWERS:
cnamestr = target.get_attribute("class")
self.assertNotIn("clickable-clicked", cnamestr)


def tearDown(self):
self.driver.quit()


if __name__ == '__main__':
if len(sys.argv) > 1:
PORT = sys.argv.pop()
unittest.main(verbosity=2)
12 changes: 11 additions & 1 deletion runestone/common/project_template/conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,20 @@ pygments_style = 'sphinx'

# `keep_warnings <http://www.sphinx-doc.org/en/stable/config.html#confval-keep_warnings>`_:
# If true, keep warnings as “system message” paragraphs in the built documents.
# Regardless of this setting, warnings are always written to the standard error
# Regardless of this setting, warnings are always written to the standard error
# stream when sphinx-build is run.
keep_warnings = True

# `rst_prolog <http://www.sphinx-doc.org/en/stable/config.html#confval-rst_prolog>`_:
# A string of reStructuredText that will be included at the beginning of every
# source file that is read.
rst_prolog = (
# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing books will need to update their conf.py in order to get this. We'll need to do that for pip, thinkcspy, pythonds, etc.

Although if I understand this correctly an author is free to use :blank:foo if they want.

Copy link
Contributor Author

@bjones1 bjones1 Jul 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct; any form of :blank:`foo` (where foo can be anything) works. Would you like me to submit PRs for these books? Or would you prefer to edit them yourself?

"""

.. |blank| replace:: :blank:`x`
"""
)

# -- Options for HTML output ---------------------------------------------------

Expand Down
Empty file.
11 changes: 11 additions & 0 deletions runestone/dragndrop/test/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# `rst_prolog <http://www.sphinx-doc.org/en/stable/config.html#confval-rst_prolog>`_:
# A string of reStructuredText that will be included at the beginning of every
# source file that is read.
rst_prolog = (
# For fill-in-the-blank questions, provide a convenient means to indicate a blank.
"""

.. |blank| replace:: :blank:`x`
"""
)


# -- Options for HTML output ---------------------------------------------------

Expand Down
Loading