def test_df_execution_quiet_with_output_var(): shell = MagicMock() shell.user_ns = {} magic = SparkMagicBase(None) magic.shell = shell df = 0 cell = SQLQuery("") session = MagicMock() output_var = "var_name" magic.spark_controller = MagicMock() magic.spark_controller.run_sqlquery = MagicMock(return_value=df) res = magic.execute_sqlquery("", None, None, None, session, output_var, True) magic.spark_controller.run_sqlquery.assert_called_once_with(cell, session) assert res is None assert shell.user_ns[output_var] == df
def test_df_execution_without_output_var(): shell = MagicMock() shell.user_ns = {} magic = SparkMagicBase(None) magic.shell = shell df = 0 query = SQLQuery("") session = MagicMock() output_var = None magic.spark_controller = MagicMock() magic.spark_controller.run_sqlquery = MagicMock(return_value=df) res = magic.execute_sqlquery("", None, None, None, session, output_var, False) magic.spark_controller.run_sqlquery.assert_called_once_with(query, session) assert res == df assert_equals(list(shell.user_ns.keys()), [])