Skip to content

Commit dcfbce8

Browse files
committed
add test
1 parent ba324ff commit dcfbce8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/sql/magic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def get_query_type(command: str):
705705

706706
def set_configs(ip, file_path, alternate_path):
707707
"""Set user defined SqlMagic configuration settings"""
708-
sql = ip.find_cell_magic("sql").__self__
708+
sql = ip.find_cell_magic("jupysql").__self__
709709
user_configs, loaded_from = util.get_user_configs(file_path, alternate_path)
710710
default_configs = util.get_default_configs(sql)
711711
table_rows = []

src/tests/test_magic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from sql.run.resultset import ResultSet
2424
from sql import magic
2525
from sql.warnings import JupySQLQuotedNamedParametersWarning
26+
from sql._testing import TestingShell
27+
from sql.magic import load_ipython_extension
2628

2729

2830
from conftest import runsql
@@ -2767,3 +2769,21 @@ def test_disabled_named_parameters_shows_disabled_warning(ip):
27672769
)
27682770

27692771
assert expected_warning in str(excinfo.value)
2772+
2773+
2774+
def test_databricks_sql_magic_disabled(monkeypatch):
2775+
monkeypatch.setenv("DATABRICKS_RUNTIME_VERSION", "10.0.0")
2776+
ip = TestingShell.preconfigured_shell()
2777+
load_ipython_extension(ip)
2778+
2779+
ip.run_cell("%jupysql duckdb://")
2780+
ip.run_cell("%jupysql select 1")
2781+
2782+
with pytest.raises(UsageError) as excinfo_line:
2783+
ip.run_cell("%sql select 1")
2784+
2785+
with pytest.raises(UsageError) as excinfo_cell:
2786+
ip.run_cell("%%sql\nselect 1")
2787+
2788+
assert "Line magic function `%sql` not found" in str(excinfo_line.value)
2789+
assert "Cell magic `%%sql` not found" in str(excinfo_cell.value)

0 commit comments

Comments
 (0)