Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit dd3b4b3

Browse files
authored
Merge pull request #1177 from bjones1/more-tests-1
Port: To pytest.
2 parents eae9a06 + c795ce1 commit dd3b4b3

3 files changed

Lines changed: 63 additions & 88 deletions

File tree

runestone/matrixeq/test/test_matrixeq.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,28 @@
22
Test Matrix Equations directive (matrixeq)
33
"""
44

5-
from unittest import TestCase
65
from selenium.webdriver.support import expected_conditions as EC
76
from selenium.webdriver.support.ui import WebDriverWait
87
from selenium.webdriver.common.by import By
9-
from runestone.unittest_base import module_fixture_maker, RunestoneTestCase
108

119
__author__ = "wayne brown"
1210

13-
mf, setUpModule, tearDownModule = module_fixture_maker(__file__, True)
1411

12+
def test_ma1(selenium_utils_get):
13+
""" matrixeq - test the click of a mutliplication operator """
14+
wait = WebDriverWait(selenium_utils_get.driver, 10)
15+
try:
16+
wait.until(EC.presence_of_element_located((By.TAG_NAME, "body")))
17+
except:
18+
text = selenium_utils_get.driver.page_source
19+
print(text[:300])
1520

16-
class Matrixeq_Tests(RunestoneTestCase):
17-
def test_ma1(self):
18-
""" matrixeq - test the click of a mutliplication operator """
19-
self.driver.get(self.host + "/index.html")
20-
wait = WebDriverWait(self.driver, 10)
21-
try:
22-
wait.until(EC.presence_of_element_located((By.TAG_NAME, "body")))
23-
except:
24-
text = self.driver.page_source
25-
print(text[:300])
26-
27-
# t1 = self.driver.find_element_by_id("question1")
28-
#
29-
# btn_check = t1.find_element_by_tag_name('button')
30-
# btn_check.click()
31-
#
32-
# fb = t1.find_element_by_id("question1_feedback")
33-
# self.assertIsNotNone(fb)
34-
# cnamestr = fb.get_attribute("class")
35-
# self.assertIn("alert-danger", cnamestr)
36-
37-
# Testing time in dominated by browser startup/shutdown. So, simply run all tests in a single browser instance to speed things up. On failures, uncomment test functions to diagnose.
38-
def test_ma2(self):
39-
"""
40-
matrixeq - test the click of an equal operator
41-
"""
42-
self.driver.get(self.host + "/index.html")
21+
# t1 = self.driver.find_element_by_id("question1")
22+
#
23+
# btn_check = t1.find_element_by_tag_name('button')
24+
# btn_check.click()
25+
#
26+
# fb = t1.find_element_by_id("question1_feedback")
27+
# self.assertIsNotNone(fb)
28+
# cnamestr = fb.get_attribute("class")
29+
# self.assertIn("alert-danger", cnamestr)
Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,50 @@
1-
from runestone.unittest_base import module_fixture_maker, RunestoneTestCase
1+
def test_hello(selenium_utils_get):
2+
"""
3+
1. Get the outer div id of the activecode component
4+
2. Find the run button using its class name
5+
3. Run the example
6+
4. Check the output from the ac_output element
7+
:return:
8+
"""
9+
t1 = selenium_utils_get.driver.find_element_by_id("qtest_1")
10+
li = t1.find_element_by_tag_name("ol")
11+
num = li.get_attribute("start")
12+
assert num == "1"
213

3-
setUpModule, tearDownModule = module_fixture_maker(__file__)
14+
class_string = t1.get_attribute("class")
15+
assert "full-width container" in class_string
416

17+
t1 = selenium_utils_get.driver.find_element_by_id("qtest_2")
18+
li = t1.find_element_by_tag_name("ol")
19+
num = li.get_attribute("start")
20+
assert num == "2"
521

6-
class QuestionTests(RunestoneTestCase):
7-
def test_hello(self):
8-
"""
9-
1. Get the outer div id of the activecode component
10-
2. Find the run button using its class name
11-
3. Run the example
12-
4. Check the output from the ac_output element
13-
:return:
14-
"""
15-
self.driver.get(self.host + "/index.html")
16-
t1 = self.driver.find_element_by_id("qtest_1")
17-
self.assertIsNotNone(t1)
18-
li = t1.find_element_by_tag_name("ol")
19-
self.assertIsNotNone(li)
20-
num = li.get_attribute("start")
21-
self.assertEqual(num, "1")
2222

23-
class_string = t1.get_attribute("class")
24-
self.assertTrue("full-width container" in class_string)
25-
26-
t1 = self.driver.find_element_by_id("qtest_2")
27-
self.assertIsNotNone(t1)
28-
li = t1.find_element_by_tag_name("ol")
29-
self.assertIsNotNone(li)
30-
num = li.get_attribute("start")
31-
self.assertEqual(num, "2")
32-
33-
# def test_mc(self):
34-
# self.driver.get(self.host + "/index.html")
35-
# t1 = self.driver.find_element_by_id("qtest_2")
36-
# cbs = t1.find_elements_by_tag_name("li")
37-
# for el in cbs:
38-
# el.click()
39-
#
40-
# checkme = t1.find_element_by_tag_name('button')
41-
# checkme.click()
42-
#
43-
# fb = t1.find_element_by_id("question1_2_feedback")
44-
# self.assertIsNotNone(fb)
45-
# cnamestr = fb.get_attribute("class")
46-
# self.assertEqual(cnamestr, "alert alert-danger")
47-
#
48-
# def test_mc2(self):
49-
# self.driver.get(self.host + "/index.html")
50-
# t1 = self.driver.find_element_by_id("qtest_2")
51-
# t1.find_element_by_id("question1_2_opt_0").click()
52-
# t1.find_element_by_id("question1_2_opt_1").click()
53-
# t1.find_element_by_id("question1_2_opt_3").click()
54-
#
55-
# checkme = t1.find_element_by_tag_name('button')
56-
# checkme.click()
57-
#
58-
# fb = t1.find_element_by_id("question1_2_feedback")
59-
# self.assertIsNotNone(fb)
60-
# cnamestr = fb.get_attribute("class")
61-
# self.assertEqual(cnamestr, "alert alert-success")
23+
# def test_mc(self):
24+
# t1 = self.driver.find_element_by_id("qtest_2")
25+
# cbs = t1.find_elements_by_tag_name("li")
26+
# for el in cbs:
27+
# el.click()
28+
#
29+
# checkme = t1.find_element_by_tag_name('button')
30+
# checkme.click()
31+
#
32+
# fb = t1.find_element_by_id("question1_2_feedback")
33+
# self.assertIsNotNone(fb)
34+
# cnamestr = fb.get_attribute("class")
35+
# assert cnamestr, "alert alert-danger")
36+
#
37+
#
38+
# def test_mc2(self):
39+
# t1 = self.driver.find_element_by_id("qtest_2")
40+
# t1.find_element_by_id("question1_2_opt_0").click()
41+
# t1.find_element_by_id("question1_2_opt_1").click()
42+
# t1.find_element_by_id("question1_2_opt_3").click()
43+
#
44+
# checkme = t1.find_element_by_tag_name('button')
45+
# checkme.click()
46+
#
47+
# fb = t1.find_element_by_id("question1_2_feedback")
48+
# self.assertIsNotNone(fb)
49+
# cnamestr = fb.get_attribute("class")
50+
# assert cnamestr, "alert alert-success")

runestone/showeval/test/test_showEval.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from runestone.conftest import selenium_utils
21
import time
32

43
import pytest

0 commit comments

Comments
 (0)