Skip to content

Commit 7ec3c4b

Browse files
style: apply ruff format to tests/test_base.py
1 parent 4dcfe67 commit 7ec3c4b

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

tests/test_base.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for SchemaForge base generator utilities (_base.py)."""
2+
23
from __future__ import annotations
34

45
import sys
@@ -18,6 +19,7 @@
1819

1920
# ── resolve_type tests ──
2021

22+
2123
def test_resolve_type_normal():
2224
"""resolve_type returns the mapped type for known ColumnTypes."""
2325
col = Column(name="id", type=ColumnType.INTEGER)
@@ -48,6 +50,7 @@ def test_resolve_type_unknown():
4850

4951
# ── build_type_string tests ──
5052

53+
5154
def test_build_type_string_simple():
5255
"""build_type_string returns base type for simple columns."""
5356
col = Column(name="id", type=ColumnType.INTEGER)
@@ -58,32 +61,41 @@ def test_build_type_string_simple():
5861
def test_build_type_string_string_with_length():
5962
"""build_type_string adds length for STRING."""
6063
col = Column(name="name", type=ColumnType.STRING, type_args={"length": 100})
61-
result = build_type_string(col, {ColumnType.STRING: "String"},
62-
string_fmt="{}({})", string_default="String")
64+
result = build_type_string(
65+
col, {ColumnType.STRING: "String"}, string_fmt="{}({})", string_default="String"
66+
)
6367
assert result == "String(100)"
6468

6569

6670
def test_build_type_string_string_no_length():
6771
"""build_type_string returns base for STRING without length."""
6872
col = Column(name="name", type=ColumnType.STRING)
69-
result = build_type_string(col, {ColumnType.STRING: "String"},
70-
string_fmt="{}({})", string_default="String")
73+
result = build_type_string(
74+
col, {ColumnType.STRING: "String"}, string_fmt="{}({})", string_default="String"
75+
)
7176
assert result == "String"
7277

7378

7479
def test_build_type_string_decimal():
7580
"""build_type_string adds precision/scale for DECIMAL."""
76-
col = Column(name="price", type=ColumnType.DECIMAL, type_args={"precision": 12, "scale": 4})
77-
result = build_type_string(col, {ColumnType.DECIMAL: "DECIMAL"},
78-
decimal_fmt="{}({},{})", decimal_default="DECIMAL")
81+
col = Column(
82+
name="price", type=ColumnType.DECIMAL, type_args={"precision": 12, "scale": 4}
83+
)
84+
result = build_type_string(
85+
col,
86+
{ColumnType.DECIMAL: "DECIMAL"},
87+
decimal_fmt="{}({},{})",
88+
decimal_default="DECIMAL",
89+
)
7990
assert result == "DECIMAL(12,4)"
8091

8192

8293
def test_build_type_string_enum():
8394
"""build_type_string formats inline ENUM values."""
84-
col = Column(name="size", type=ColumnType.ENUM, type_args={"values": ["S", "M", "L"]})
85-
result = build_type_string(col, {ColumnType.ENUM: "Enum"},
86-
enum_fmt="Enum({})")
95+
col = Column(
96+
name="size", type=ColumnType.ENUM, type_args={"values": ["S", "M", "L"]}
97+
)
98+
result = build_type_string(col, {ColumnType.ENUM: "Enum"}, enum_fmt="Enum({})")
8799
assert result == "Enum('S', 'M', 'L')"
88100

89101

@@ -97,8 +109,12 @@ def test_build_type_string_custom():
97109
def test_build_type_string_sql_varchar():
98110
"""build_type_string produces VARCHAR with length when type_map has VARCHAR."""
99111
col = Column(name="name", type=ColumnType.STRING, type_args={"length": 255})
100-
result = build_type_string(col, {ColumnType.STRING: "VARCHAR"},
101-
string_fmt="{}({})", string_default="VARCHAR")
112+
result = build_type_string(
113+
col,
114+
{ColumnType.STRING: "VARCHAR"},
115+
string_fmt="{}({})",
116+
string_default="VARCHAR",
117+
)
102118
assert result == "VARCHAR(255)"
103119

104120

@@ -119,6 +135,7 @@ def test_build_type_string_with_fn_default():
119135

120136
# ── resolve_fn_default tests ──
121137

138+
122139
def test_resolve_fn_default_now():
123140
"""resolve_fn_default maps CURRENT_TIMESTAMP to now()."""
124141
col = Column(name="ts", type=ColumnType.DATETIME, default="fn:CURRENT_TIMESTAMP")
@@ -186,6 +203,7 @@ def test_resolve_fn_default_all_mapped_fns():
186203

187204
# ── format_literal_default tests ──
188205

206+
189207
def test_format_literal_default_bool():
190208
"""format_literal_default formats boolean defaults."""
191209
col = Column(name="active", type=ColumnType.BOOLEAN, default=True)
@@ -230,6 +248,7 @@ def test_format_literal_default_fn():
230248

231249
# ── FN_DEFAULT_MAP constants ──
232250

251+
233252
def test_fn_default_map_has_expected_keys():
234253
"""FN_DEFAULT_MAP should have the core SQL function constants."""
235254
assert "CURRENT_TIMESTAMP" in FN_DEFAULT_MAP

0 commit comments

Comments
 (0)