-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathhelper.py
More file actions
61 lines (48 loc) · 1.53 KB
/
Copy pathhelper.py
File metadata and controls
61 lines (48 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from protowhat.Reporter import Reporter
from protowhat.sct_syntax import link_to_state
from sqlwhat.State import State
from sqlwhat.checks import (
check_row,
check_column,
check_all_columns,
check_result,
lowercase,
has_equal_value,
has_no_error, has_result, has_nrows, has_ncols)
check_row = link_to_state(check_row)
check_column = link_to_state(check_column)
check_all_columns = link_to_state(check_all_columns)
check_result = link_to_state(check_result)
lowercase = link_to_state(lowercase)
has_equal_value = link_to_state(has_equal_value)
def get_sct_payload(output):
output = [out for out in output if out["type"] == "sct"]
if len(output) > 0:
return output[0]["payload"]
else:
print(output)
return None
class Connection:
"""Mock up conn.dialect.name"""
def __init__(self, dialect_name):
self.dialect = lambda: None
self.dialect.name = dialect_name
def prepare_state(sol_result, stu_result, error=None):
conn = Connection("postgresql")
return State(
student_code="",
solution_code="",
reporter=Reporter(errors=error),
# args below should be ignored
pre_exercise_code="NA",
student_result=stu_result,
solution_result=sol_result,
student_conn=conn,
solution_conn=None,
)
def passes(x):
assert isinstance(x, State)
has_no_error = link_to_state(has_no_error)
has_result = link_to_state(has_result)
has_nrows = link_to_state(has_nrows)
has_ncols = link_to_state(has_ncols)