Skip to content

Commit 69c85aa

Browse files
william-contiJCZuurmond
authored andcommitted
adding failed test
1 parent 05593cd commit 69c85aa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/unit/source_code/linters/test_pyspark.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ def test_spark_dynamic_sql(empty_index) -> None:
3030
sqf = SparkTableNamePyLinter(ftf, empty_index, session_state)
3131
assert not list(sqf.lint(source))
3232

33+
def test_dbfs_stuff(empty_index) -> None:
34+
source = """
35+
# Databricks notebook source
36+
# MAGIC %run ./_param_connexion_formation
37+
38+
# COMMAND ----------
39+
40+
from pyspark.sql import functions as F
41+
42+
# COMMAND ----------
43+
44+
path_dossierLIZZY = searchPathRecent('/mnt/mnt_datalake_smartCompetencies/', repLIZZY)
45+
"""
46+
session_state = CurrentSessionState()
47+
ftf = FromTableSqlLinter(empty_index, session_state)
48+
sqf = SparkTableNamePyLinter(ftf, empty_index, session_state)
49+
assert not list(sqf.lint(source))
3350

3451
def test_linter_context_python_linter_lints_table_pending_migration_with_empty_index(empty_index) -> None:
3552
source_code = """
@@ -526,6 +543,20 @@ def test_from_table_sql_py_linter_fixes_migrated_table(migration_index) -> None:
526543
)
527544
],
528545
),
546+
# Test for mount calls inside a function
547+
(
548+
"""variable = searchPath('/mnt/something/', some_variable)""",
549+
[
550+
Deprecation(
551+
code='direct-filesystem-access',
552+
message="The use of direct filesystem references is deprecated: /mnt/something/",
553+
start_line=0,
554+
start_col=0,
555+
end_line=0,
556+
end_col=41,
557+
)
558+
],
559+
),
529560
],
530561
)
531562
def test_spark_cloud_direct_access(empty_index, code, expected) -> None:
@@ -656,3 +687,4 @@ def test_spark_collect_tables_ignores_dfsas(source_code, expected, migration_ind
656687
for used_table in used_tables:
657688
actual = (used_table.catalog_name, used_table.schema_name, used_table.table_name)
658689
assert actual in expected
690+

0 commit comments

Comments
 (0)