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

Commit 152764a

Browse files
committed
black
1 parent 8c241b3 commit 152764a

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

runestone/activecode/test/test_activecode.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def click_run(selenium_utils, ac_selenium_element):
1818
rb.click()
1919
# After clicking run, the browser may need some time to load and execute the code. Wait until the run button becomes clickable, indicating the code has finished running.
2020
div_id = ac_selenium_element.get_attribute("id")
21-
selenium_utils.wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, f"#{div_id} .run-button")))
21+
selenium_utils.wait.until(EC.element_to_be_clickable(
22+
(By.CSS_SELECTOR, f"#{div_id} .run-button")))
2223

2324

2425
def test_hello(selenium_utils_get):
@@ -75,7 +76,7 @@ def test_history(selenium_utils_get):
7576
ta = t1.find_element_by_class_name("cm-s-default")
7677
assert ta
7778
selenium_utils_get.driver.execute_script(
78-
f"""window.edList['{div_id}'].editor.setValue("print('Goodbye')")"""
79+
f"""window.componentMap['{div_id}'].editor.setValue("print('Goodbye')")"""
7980
)
8081
click_run(selenium_utils_get, t1)
8182
output = t1.find_element_by_class_name("ac_output")
@@ -111,14 +112,17 @@ def test_activity_count(selenium_utils_progress):
111112
click_run(selenium_utils_progress, t2)
112113
pb = selenium_utils_progress.driver.find_element_by_id("subchapterprogress")
113114
assert pb
114-
total = selenium_utils_progress.driver.find_element_by_id("scprogresstotal").text.strip()
115+
total = selenium_utils_progress.driver.find_element_by_id(
116+
"scprogresstotal").text.strip()
115117
assert 2 == int(total)
116-
possible = selenium_utils_progress.driver.find_element_by_id("scprogressposs").text.strip()
118+
possible = selenium_utils_progress.driver.find_element_by_id(
119+
"scprogressposs").text.strip()
117120
# expect only 1 because the page isn't included when not using services
118121
assert 2 == int(possible)
119122
# count should not increment after a second click
120123
click_run(selenium_utils_progress, t2)
121-
total = selenium_utils_progress.driver.find_element_by_id("scprogresstotal").text.strip()
124+
total = selenium_utils_progress.driver.find_element_by_id(
125+
"scprogresstotal").text.strip()
122126
assert 2 == int(total)
123127

124128

@@ -128,7 +132,8 @@ def test_sql_activecode(selenium_utils_get):
128132
# 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.
129133
time.sleep(2)
130134
click_run(selenium_utils_get, t2)
131-
selenium_utils_get.wait.until(EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "You"))
135+
selenium_utils_get.wait.until(
136+
EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "You"))
132137
res = selenium_utils_get.driver.find_element_by_id(f"{div_id}_sql_out")
133138
assert res
134139
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
@@ -146,7 +151,7 @@ def test_sql_activecode(selenium_utils_get):
146151
ta = t1.find_element_by_class_name("cm-s-default")
147152
assert ta
148153
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');")"""
154+
f"""window.componentMap['{div_id}'].editor.setValue("CREATE TABLE created_table (x TEXT); INSERT INTO created_table VALUES ('itworks');")"""
150155
)
151156
click_run(selenium_utils_get, t1)
152157

@@ -155,12 +160,14 @@ def test_sql_activecode(selenium_utils_get):
155160
# 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.
156161
time.sleep(2)
157162
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"))
163+
selenium_utils_get.wait.until(
164+
EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "You"))
159165
res = selenium_utils_get.driver.find_element_by_id(f"{div_id}_sql_out")
160166
assert res
161167
out = selenium_utils_get.driver.find_element_by_id(f"{div_id}_stdout")
162168
assert "You passed 1 out of 1 tests" in out.text
163169

170+
164171
@pytest.fixture
165172
def selenium_utils_sf(selenium_utils):
166173
selenium_utils.get("skulptfeatures.html")

runestone/timed/test/test_timed.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def _test_1(selenium_utils_mq, timed_divid):
9595
src, dest = dnd.find_elements_by_class_name("rsdraggable")
9696
src_items = src.find_elements_by_tag_name("span")
9797
for i in range(3):
98-
selenium_utils_mq.driver.execute_script(f"""$("#{src_items[i].get_attribute('id')}").simulateDragDrop({{ dropTarget: 'span:contains("Answer {src_items[i].text[8:]}")' }})""")
98+
selenium_utils_mq.driver.execute_script(
99+
f"""$("#{src_items[i].get_attribute('id')}").simulateDragDrop({{ dropTarget: 'span:contains("Answer {src_items[i].text[8:]}")' }})""")
99100
selenium_utils_mq.scroll_to_top()
100101
next.click()
101102

@@ -110,27 +111,33 @@ def _test_1(selenium_utils_mq, timed_divid):
110111
div_id = "test_timed_activecode_1"
111112
selenium_utils_mq.wait_until_ready(div_id)
112113
selenium_utils_mq.driver.execute_script(
113-
f"""window.edList['{div_id}'].editor.setValue("def add(a, b): return a + b")"""
114+
f"""window.componentMap['{div_id}'].editor.setValue("def add(a, b): return a + b")"""
114115
)
115116
next.click()
116117

117118
# The Parson's problem.
118119
selenium_utils_mq.wait_until_ready("test_timed_parsons_1")
119120
# This is an ugly hack, since Parson's problems number problems sequentially instead of based on the problem's ID. The div_id happens to match the ordering of Parson's problems...
120121
parsons_counter = timed_divid[-1]
121-
source = selenium_utils_mq.driver.find_element_by_id(f"parsons-{parsons_counter}-source")
122-
answer = selenium_utils_mq.driver.find_element_by_id(f"parsons-{parsons_counter}-answer")
123-
dragndrop(selenium_utils_mq, source.find_element_by_id(f"parsons-{parsons_counter}-block-0"), answer)
122+
source = selenium_utils_mq.driver.find_element_by_id(
123+
f"parsons-{parsons_counter}-source")
124+
answer = selenium_utils_mq.driver.find_element_by_id(
125+
f"parsons-{parsons_counter}-answer")
126+
dragndrop(selenium_utils_mq, source.find_element_by_id(
127+
f"parsons-{parsons_counter}-block-0"), answer)
124128
time.sleep(1)
125-
dragndrop(selenium_utils_mq, source.find_element_by_id(f"parsons-{parsons_counter}-block-2"), answer)
129+
dragndrop(selenium_utils_mq, source.find_element_by_id(
130+
f"parsons-{parsons_counter}-block-2"), answer)
126131
time.sleep(1)
127-
dragndrop(selenium_utils_mq, source.find_element_by_id(f"parsons-{parsons_counter}-block-1"), answer)
132+
dragndrop(selenium_utils_mq, source.find_element_by_id(
133+
f"parsons-{parsons_counter}-block-1"), answer)
128134
next.click()
129135

130136
# The short answer question.
131137
div_id = "test_timed_shortanswer_1"
132138
selenium_utils_mq.wait_until_ready(div_id)
133-
selenium_utils_mq.driver.find_element_by_id(f"{div_id}_solution").send_keys("ROYGBIV circle area")
139+
selenium_utils_mq.driver.find_element_by_id(
140+
f"{div_id}_solution").send_keys("ROYGBIV circle area")
134141

135142
finish(selenium_utils_mq)
136143
div_id = f"{timed_divid}results"

0 commit comments

Comments
 (0)