in core/lib/hook.py [0:0]
def execute_sqls(self):
"""
Execute the given sql against MySQL without caring about the result
output
"""
# If the first line start with 'SELECT' then it's an assertion. We
# should check the result set we get from MySQL against the rows
# written as the rest of the SQL file
if self._is_select:
result = self._dbh.query_array(self._sqls[0])
if len(result) != len(self._expected_lines):
raise OSCError(
"ASSERTION_ERROR",
{
"expected": "{} lines of result set".format(
len(self._expected_lines)
),
"got": "{} lines of result set".format(len(result)),
},
)
for idx, expected_row in enumerate(self._expected_lines):
got_line = "\t".join([str(col) for col in result[idx]])
if got_line != expected_row:
raise OSCError(
"ASSERTION_ERROR", {"expected": expected_row, "got": got_line}
)
else:
for sql in self._sqls:
log.debug("Running the following SQL on MySQL: {} ".format(sql))
self._dbh.execute(sql)