Skip to content

Commit aaf6a23

Browse files
style: apply ruff format to tests/test_type_config.py
1 parent b8fb0ac commit aaf6a23

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tests/test_type_config.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for SchemaForge custom type mapping configuration (type_config.py)."""
2+
23
from __future__ import annotations
34

45
import json
@@ -16,6 +17,7 @@
1617

1718
# ── Basic TypeConfig Tests ──
1819

20+
1921
def test_empty_config_returns_none():
2022
"""Empty TypeConfig returns None for all lookups."""
2123
col = Column(name="id", type=ColumnType.INTEGER)
@@ -58,15 +60,19 @@ def test_config_with_length_placeholder():
5860
def test_config_with_precision_scale():
5961
"""TypeConfig replaces {precision} and {scale} placeholders."""
6062
config = TypeConfig({"sql": {"DECIMAL": "DECIMAL({precision},{scale})"}})
61-
col = Column(name="price", type=ColumnType.DECIMAL, type_args={"precision": 12, "scale": 4})
63+
col = Column(
64+
name="price", type=ColumnType.DECIMAL, type_args={"precision": 12, "scale": 4}
65+
)
6266
result = config.get_override(col, "sql")
6367
assert result == "DECIMAL(12,4)"
6468

6569

6670
def test_config_with_enum_values():
6771
"""TypeConfig replaces {values} placeholder."""
6872
config = TypeConfig({"sql": {"ENUM": "ENUM({values})"}})
69-
col = Column(name="size", type=ColumnType.ENUM, type_args={"values": ["S", "M", "L"]})
73+
col = Column(
74+
name="size", type=ColumnType.ENUM, type_args={"values": ["S", "M", "L"]}
75+
)
7076
result = config.get_override(col, "sql")
7177
assert result == "ENUM('S', 'M', 'L')"
7278

@@ -81,6 +87,7 @@ def test_config_unresolved_placeholder_removed():
8187

8288
# ── File Loading Tests ──
8389

90+
8491
def test_load_from_json():
8592
"""TypeConfig can be loaded from a JSON file."""
8693
data = {"overrides": {"sql": {"INTEGER": "BIGINT"}}}
@@ -119,7 +126,11 @@ def test_load_from_yaml_without_pyyaml():
119126
f.write("overrides:\n sql:\n INTEGER: BIGINT\n")
120127
tmp_path = f.name
121128
try:
122-
_orig_import = __builtins__["__import__"] if isinstance(__builtins__, dict) else __builtins__.__import__
129+
_orig_import = (
130+
__builtins__["__import__"]
131+
if isinstance(__builtins__, dict)
132+
else __builtins__.__import__
133+
)
123134

124135
def _mock_import(name, *args, **kw):
125136
if name == "yaml":
@@ -181,6 +192,7 @@ def test_file_not_found():
181192

182193
# ── Merge Tests ──
183194

195+
184196
def test_merge_two_configs():
185197
"""Merging configs combines overrides (other takes precedence)."""
186198
base = TypeConfig({"sql": {"INTEGER": "INT", "STRING": "TEXT"}})
@@ -191,7 +203,7 @@ def test_merge_two_configs():
191203
col_str = Column(name="name", type=ColumnType.STRING)
192204

193205
assert merged.get_override(col_int, "sql") == "BIGINT" # Overridden
194-
assert merged.get_override(col_str, "sql") == "TEXT" # Preserved
206+
assert merged.get_override(col_str, "sql") == "TEXT" # Preserved
195207

196208

197209
def test_merge_different_formats():
@@ -207,6 +219,7 @@ def test_merge_different_formats():
207219

208220
# ── Integration Tests ──
209221

222+
210223
def test_type_config_in_convert_sql_to_prisma():
211224
"""TypeConfig overrides applied through convert_schema API."""
212225
sql = """

0 commit comments

Comments
 (0)