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

Commit fe7b3c6

Browse files
committed
Fix: Update div_ids used in testing.
1 parent 9cf96a9 commit fe7b3c6

3 files changed

Lines changed: 25 additions & 28 deletions

File tree

runestone/activecode/test/_sources/index.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
ActiveCode Test
44
===============
5+
Note: an existing server-side test is named ``test_activecode_1``. So, we start numbering here at 2.
56

6-
7-
.. activecode:: test1
7+
.. activecode:: test_activecode_2
88

99
print("Hello World")
1010

1111

12-
End of test1
13-
14-
.. activecode:: test1a
12+
.. activecode:: test_activecode_2a
1513

1614
This question has multiple lines of explanatory
1715
text prior to the editing area or scaffolded code.
@@ -50,7 +48,7 @@ End of test1
5048
}
5149
}
5250

53-
.. activecode:: test2
51+
.. activecode:: test_activecode_3
5452
:language: java
5553
:datafile: Shape.java
5654

@@ -87,7 +85,7 @@ End of test1
8785
</script>
8886

8987

90-
.. activecode:: Picture
88+
.. activecode:: test_activecode_4
9189
:language: java
9290
:datafile: turtleClasses.jar, arch.jpg
9391

@@ -213,9 +211,7 @@ End of test1
213211

214212
Support for SQL in the browser ? Yes!
215213
--------------------------------------
216-
217-
218-
.. activecode:: sql1
214+
.. activecode:: test_activecode_6
219215
:language: sql
220216
:autograde: unittest
221217
:dburl: /_static/test.db
@@ -230,7 +226,7 @@ Support for SQL in the browser ? Yes!
230226
.. :dburl: http://dev.runestoneinteractive.org:8080/_static/bikeshare.db
231227
232228
233-
.. activecode:: sql2
229+
.. activecode:: test_activecode_7
234230
:language: sql
235231
:autograde: unittest
236232
:dburl: /_static/test.db

runestone/activecode/test/_sources/progresspage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Progress Bar Testing
22
====================
33

4-
.. activecode:: test_p1
4+
.. activecode:: test_activecode_5
55

66
print("Hello World")
77

runestone/activecode/test/test_activecode.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ def test_hello(selenium_utils_get):
2727
4. Check the output from the ac_output element
2828
:return:
2929
"""
30-
t1 = find_ac(selenium_utils_get, "test1")
30+
div_id = "test_activecode_2"
31+
t1 = find_ac(selenium_utils_get, div_id)
3132
click_run(t1)
3233
selenium_utils_get.wait.until(
33-
EC.text_to_be_present_in_element((By.ID, "test1_stdout"), "Hello World"),
34+
EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "Hello World"),
3435
message="Did not find expected text",
3536
)
3637
output = t1.find_element_by_class_name("ac_output")
@@ -65,17 +66,17 @@ def test_history(selenium_utils_get):
6566
4. Check the output from the ac_output element
6667
:return:
6768
"""
68-
#import pdb; pdb.set_trace()
69-
t1 = find_ac(selenium_utils_get, "test1")
70-
selenium_utils_get.driver.execute_script("window.scrollTo(0, 0);")
69+
div_id = "test_activecode_2"
70+
t1 = find_ac(selenium_utils_get, div_id)
71+
time.sleep(1)
7172
rb = t1.find_element_by_class_name("run-button")
7273
rb.click()
7374
time.sleep(2)
7475

7576
ta = t1.find_element_by_class_name("cm-s-default")
7677
assert ta
7778
selenium_utils_get.driver.execute_script(
78-
"""window.edList['test1'].editor.setValue("print('GoodBye')")"""
79+
f"""window.edList['{div_id}'].editor.setValue("print('GoodBye')")"""
7980
)
8081
selenium_utils_get.wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "run-button")))
8182
try:
@@ -109,7 +110,7 @@ def test_livecode_datafile(selenium_utils_get):
109110
Runs test2 example
110111
Code is dependent on supplementary file
111112
"""
112-
t2 = find_ac(selenium_utils_get, "test2")
113+
t2 = find_ac(selenium_utils_get, "test_activecode_3")
113114
click_run(t2)
114115
output = t2.find_element_by_class_name("ac_output")
115116

@@ -133,7 +134,7 @@ def selenium_utils_progress(selenium_utils):
133134

134135

135136
def test_activity_count(selenium_utils_progress):
136-
t2 = find_ac(selenium_utils_progress, "test_p1")
137+
t2 = find_ac(selenium_utils_progress, "test_activecode_5")
137138
click_run(t2)
138139
pb = selenium_utils_progress.driver.find_element_by_id("subchapterprogress")
139140
assert pb
@@ -151,19 +152,19 @@ def test_activity_count(selenium_utils_progress):
151152

152153

153154
def test_sql_activecode(selenium_utils_get):
154-
t2 = find_ac(selenium_utils_get, "sql1")
155-
time.sleep(1)
155+
div_id = "test_activecode_6"
156+
t2 = find_ac(selenium_utils_get, div_id)
156157
click_run(t2)
157-
selenium_utils_get.wait.until(EC.text_to_be_present_in_element((By.ID, "sql1_stdout"), "You"))
158-
res = selenium_utils_get.driver.find_element_by_id("sql1_sql_out")
158+
selenium_utils_get.wait.until(EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "You"))
159+
res = selenium_utils_get.driver.find_element_by_id(f"{div_id}_sql_out")
159160
assert res
160-
out = selenium_utils_get.driver.find_element_by_id("sql1_stdout")
161+
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
161162
assert "You passed 2 out of 3 tests" in out.text
162163

163-
t2 = selenium_utils_get.driver.find_element_by_id("sql2")
164-
time.sleep(1)
164+
div_id = "test_activecode_7"
165+
t2 = find_ac(selenium_utils_get, div_id)
165166
click_run(t2)
166-
out = selenium_utils_get.driver.find_element_by_id("sql2_stdout")
167+
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
167168
assert "" == out.text.strip()
168169

169170

0 commit comments

Comments
 (0)