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

Commit e2930fe

Browse files
Test for previous change to SQL activecode.
1 parent f9fdbc4 commit e2930fe

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

runestone/activecode/test/_sources/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ Support for SQL in the browser ? Yes!
233233

234234
select * from test;
235235

236+
.. activecode:: test_activecode_6b
237+
:language: sql
238+
:autograde: unittest
239+
:dburl: /_static/test.db
240+
241+
select * from created_table;
242+
243+
=====
244+
assert 0,0 == itworks
236245

237246
.. activecode:: sql3
238247
:language: sql

runestone/activecode/test/test_activecode.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,26 @@ def test_sql_activecode(selenium_utils_get):
140140
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
141141
assert "" == out.text.strip()
142142

143+
div_id = "test_activecode_6"
144+
t1 = find_ac(selenium_utils_get, div_id)
145+
click_run(selenium_utils_get, t1)
146+
ta = t1.find_element_by_class_name("cm-s-default")
147+
assert ta
148+
selenium_utils_get.driver.execute_script(
149+
f"""window.edList['{div_id}'].editor.setValue("CREATE TABLE created_table (x TEXT); INSERT INTO created_table VALUES ('itworks');")"""
150+
)
151+
click_run(selenium_utils_get, t1)
152+
153+
div_id = "test_activecode_6b"
154+
t2 = find_ac(selenium_utils_get, div_id)
155+
# TODO: We don't yet have a way for async operations in ActiveCode constructors to signal when they're complete. So, insert a delay to guesstimate when the async load of the SQL WASM code and other async functions complete.
156+
time.sleep(2)
157+
click_run(selenium_utils_get, t2)
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")
160+
assert res
161+
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
162+
assert "You passed 1 out of 1 tests" in out.text
143163

144164
@pytest.fixture
145165
def selenium_utils_sf(selenium_utils):

0 commit comments

Comments
 (0)