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
Beispiel #2
0
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_cell_sql = MagicMock(return_value=df)

    res = magic.execute_sqlquery(query, session, output_var, False)

    magic.spark_controller.run_cell_sql.assert_called_once_with(query, session)
    assert res == df
    assert_equals(list(shell.user_ns.keys()), [])
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()), [])
Beispiel #4
0
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_cell_sql = MagicMock(return_value=df)

    res = magic.execute_sqlquery(cell, session, output_var, True)

    magic.spark_controller.run_cell_sql.assert_called_once_with(cell, session)
    assert res is None
    assert shell.user_ns[output_var] == df
def test_df_execution_quiet_without_output_var():
    shell = MagicMock()
    shell.user_ns = {}
    magic = SparkMagicBase(None)
    magic.shell = shell

    df = 0
    cell = SQLQuery("")
    session = MagicMock()
    output_var = None

    magic.spark_controller = MagicMock()
    magic.spark_controller.run_cell_sql = MagicMock(return_value=df)

    res = magic.execute_sqlquery(cell, session, output_var, True)

    magic.spark_controller.run_cell_sql.assert_called_once_with(cell, session)
    assert res is None
    assert_equals(list(shell.user_ns.keys()), [])
def test_df_execution_with_output_var():
    shell = MagicMock()
    shell.user_ns = {}
    magic = SparkMagicBase(None)
    magic.shell = shell

    df = 0
    query = SQLQuery("")
    session = MagicMock()
    output_var = "var_name"

    magic.spark_controller = MagicMock()
    magic.spark_controller.run_cell_sql = MagicMock(return_value=df)

    res = magic.execute_sqlquery(query, session, output_var, False)

    magic.spark_controller.run_cell_sql.assert_called_once_with(query, session)
    assert res == df
    assert shell.user_ns[output_var] == df
def test_df_execution_throws():
    shell = MagicMock()
    shell.user_ns = {}
    magic = SparkMagicBase(None)
    magic.shell = shell
    error = "error"

    query = SQLQuery("")
    session = MagicMock()
    output_var = "var_name"

    magic.spark_controller = MagicMock()
    magic.spark_controller.run_cell_sql = MagicMock(side_effect=DataFrameParseException(error))

    res = magic.execute_sqlquery(query, session, output_var, False)

    magic.spark_controller.run_cell_sql.assert_called_once_with(query, session)
    assert res is None
    assert_equals(list(shell.user_ns.keys()), [])
Beispiel #8
0
def test_df_execution_throws():
    shell = MagicMock()
    shell.user_ns = {}
    magic = SparkMagicBase(None)
    magic.shell = shell
    error = "error"

    query = SQLQuery("")
    session = MagicMock()
    output_var = "var_name"

    magic.spark_controller = MagicMock()
    magic.spark_controller.run_cell_sql = MagicMock(
        side_effect=DataFrameParseException(error))

    res = magic.execute_sqlquery(query, session, output_var, False)

    magic.spark_controller.run_cell_sql.assert_called_once_with(query, session)
    assert res is None
    assert_equals(list(shell.user_ns.keys()), [])
def test_print_endpoint_info_doesnt_throw():
    SparkMagicBase.print_endpoint_info(range(5))
Beispiel #10
0
def test_print_endpoint_info_doesnt_throw():
    SparkMagicBase.print_endpoint_info(range(5))