Skip to content

Commit 3c6a7ea

Browse files
committed
test: move the rename and move batch fixtures to macro kind folders
1 parent 84dfaee commit 3c6a7ea

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎tests/e2e/src/sqlbuild/cli/commands/main/refactor/test_project_failures.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
)
2121

2222
_DUPLICATE_MACROS: dict[str, str] = {
23-
"macros/cents.py": 'def to_cents(expression: str) -> str:\n return f"({expression}) * 100"\n',
24-
"macros/money.py": 'def to_cents(expression: str) -> str:\n return f"({expression}) * 100"\n',
23+
"macros/python/cents.py": 'def to_cents(expression: str) -> str:\n return f"({expression}) * 100"\n',
24+
"macros/python/money.py": 'def to_cents(expression: str) -> str:\n return f"({expression}) * 100"\n',
2525
}
2626
_UNKNOWN_REFERENCE: dict[str, str] = {
2727
"models/marts/order_gaps.sql": (

‎tests/e2e/src/sqlbuild/cli/commands/main/refactor/test_python_import_moves.py‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
write_orders_project,
2121
)
2222

23-
_MOVED: str = "models.finance._sqlbuild._macros.cents"
23+
_MOVED: str = "models.finance._sqlbuild._macros.python.cents"
2424

2525

2626
@pytest.mark.parametrize(
@@ -30,9 +30,9 @@
3030
description="direct, aliased and grouped imports of a carried macro module",
3131
files={
3232
**cents_check(
33-
"from models.staging._sqlbuild._macros.cents import to_cents\n"
34-
"import models.staging._sqlbuild._macros.cents as cents_module\n"
35-
"from models.staging._sqlbuild._macros.cents import (\n to_cents as cents,\n)",
33+
"from models.staging._sqlbuild._macros.python.cents import to_cents\n"
34+
"import models.staging._sqlbuild._macros.python.cents as cents_module\n"
35+
"from models.staging._sqlbuild._macros.python.cents import (\n to_cents as cents,\n)",
3636
body=' assert to_cents("1") == cents_module.to_cents("1") == cents("1")\n',
3737
),
3838
},
@@ -48,23 +48,23 @@
4848
description="a relative import from a macro module that stays",
4949
files={
5050
**cents_check(
51-
"from models.staging._sqlbuild._macros import cents as cents_module",
51+
"from models.staging._sqlbuild._macros.python import cents as cents_module",
5252
body=' assert cents_module.to_cents("1")\n',
5353
),
54-
"models/staging/_sqlbuild/_macros/totals.py": (
54+
"models/staging/_sqlbuild/_macros/python/totals.py": (
5555
"from .cents import to_cents\n\n\n"
5656
"def order_total(expression: str) -> str:\n"
5757
' return f"SUM({to_cents(expression)})"\n'
5858
),
5959
"models/staging/stg_order_totals.sql": (
6060
"MODEL (description 'Test model stg_order_totals.',\n materialized view,\n);\n\n"
61-
'SELECT\n @order_total("amount") AS total_cents\nFROM __ref("stg_orders")\n'
61+
'SELECT\n @py.order_total("amount") AS total_cents\nFROM __ref("stg_orders")\n'
6262
),
6363
},
6464
expected_fragments={
65-
CENTS_CHECK: ("from macros import cents as cents_module",),
66-
"models/staging/_sqlbuild/_macros/totals.py": (
67-
"from macros.cents import to_cents\n",
65+
CENTS_CHECK: ("from macros.python import cents as cents_module",),
66+
"models/staging/_sqlbuild/_macros/python/totals.py": (
67+
"from macros.python.cents import to_cents\n",
6868
),
6969
},
7070
),
@@ -102,38 +102,38 @@ def test_given_python_imports_of_a_moved_macro_when_moving_then_imports_follow_a
102102
description="a dynamic import naming the macro module",
103103
files=cents_check(
104104
"import importlib\n\n"
105-
'CENTS = importlib.import_module("models.staging._sqlbuild._macros.cents")',
105+
'CENTS = importlib.import_module("models.staging._sqlbuild._macros.python.cents")',
106106
body=' assert CENTS.to_cents("1")\n',
107107
),
108108
expected_location=f"{CENTS_CHECK}:6:9",
109109
expected_reason=(
110-
"imports models.staging._sqlbuild._macros.cents dynamically by name, which "
110+
"imports models.staging._sqlbuild._macros.python.cents dynamically by name, which "
111111
"cannot be rewritten safely"
112112
),
113113
),
114114
PythonImportRefusalE2ETestCase(
115115
description="a star import from the macro module's package",
116116
files=cents_check(
117-
"from models.staging._sqlbuild._macros.cents import *\n"
118-
"from models.staging._sqlbuild._macros import *"
117+
"from models.staging._sqlbuild._macros.python.cents import *\n"
118+
"from models.staging._sqlbuild._macros.python import *"
119119
),
120120
expected_location=f"{CENTS_CHECK}:5:1",
121121
expected_reason=(
122-
"star-imports the package of models.staging._sqlbuild._macros.cents, which moves"
122+
"star-imports the package of models.staging._sqlbuild._macros.python.cents, which moves"
123123
),
124124
),
125125
PythonImportRefusalE2ETestCase(
126126
description="an import without an alias",
127127
files=cents_check(
128-
"import models.staging._sqlbuild._macros.cents",
129-
body=' assert models.staging._sqlbuild._macros.cents.to_cents("1")\n',
128+
"import models.staging._sqlbuild._macros.python.cents",
129+
body=' assert models.staging._sqlbuild._macros.python.cents.to_cents("1")\n',
130130
),
131131
expected_location=f"{CENTS_CHECK}:4:8",
132-
expected_reason="imports models.staging._sqlbuild._macros.cents without an alias",
132+
expected_reason="imports models.staging._sqlbuild._macros.python.cents without an alias",
133133
),
134134
PythonImportRefusalE2ETestCase(
135135
description="a project Python file that is not UTF-8",
136-
files=cents_check("from models.staging._sqlbuild._macros.cents import to_cents"),
136+
files=cents_check("from models.staging._sqlbuild._macros.python.cents import to_cents"),
137137
binary_files={"rules/legacy.py": b"LABEL = '\xe9'\n"},
138138
expected_location="rules/legacy.py",
139139
expected_reason="this Python file cannot be read as UTF-8",

0 commit comments

Comments
 (0)