Closed filipsch closed 5 years ago
@richierocks, @hermansje and I have worked on an improved version. Basically, this is how you would now check whether running a query returns the same table after executing the student/solution code (that would contain INSERT
statements, for example):
Ex().check_query('SELECT COUNT(*) FROM company').has_equal_value()
What this does, as mentioned before:
check_query()
in a transaction and fetch the result.check_query()
in a transaction and fetch the result.check_column()
(if you want to further zoom in), has_equal_value()
etc.has_equal_value()
will then compare these results.Thus, in a sense, check_query()
is 'overriding' the query result that the student's submission and solution generated and that is stored in Ex()
.
Looks good?
One thing to note is that is you want to check arbitrary expressions, the syntax is pretty different across languages.
R:
ex() %>% check_expr('some code') %>% check_result() %>% check_equal()
Shell:
Ex().has_expr_output(expr='some command', output='some output')
SQL:
Ex().check_query('SELECT something').has_equal_value()
@hermansje figuring out how to synchronize the check syntax across the *what packages would be a good long term project.
I'd like to second what @richierocks has said above. As someone who frequently switches back and forth between languages writing SCTs, it gets difficult with the inconsistency in function names.
@klmedeiros @richierocks I understand your concerns, and @hermansje and I talked about it at length. Before I go, I will make sure to list out exactly which functions are used where and how, and Jeroen can then think about how things can be made more consistent.
However, some thoughts:
has_equal_value()
. The latter is running both the solution and the student code, while has_expr_output()
only runs student code.@filipsch Thank you for the context in your response, that's very helpful for me!
@richierocks these changes would include a new function in
sqlwhat
, calledcheck_query()
, that allows you to run arbitrary sql statements after rerunning the student query, so you can verify whether UPDATEs, INSERTs etc happened correctly. Let me know what you think, if you have an opinion. The docs insqlwhat/checks/check_funcs.py
are most interesting for you.