Skip to content

Commit 7efa4fc

Browse files
committed
style: format test files with Black
Apply Black formatting to: - tests/unit/test_connection.py - tests/unit/test_schema.py - tests/unit/test_executor.py - tests/integration/test_database.py
1 parent 7cbd1a2 commit 7efa4fc

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

tests/integration/test_database.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,54 @@ async def test_engine() -> AsyncEngine:
2727
# Create test tables
2828
async with engine.begin() as conn:
2929
await conn.execute(
30-
text("""
30+
text(
31+
"""
3132
CREATE TABLE customers (
3233
id INTEGER PRIMARY KEY AUTOINCREMENT,
3334
name VARCHAR(100) NOT NULL,
3435
email VARCHAR(255),
3536
state VARCHAR(50)
3637
)
37-
""")
38+
"""
39+
)
3840
)
3941

4042
await conn.execute(
41-
text("""
43+
text(
44+
"""
4245
CREATE TABLE orders (
4346
id INTEGER PRIMARY KEY AUTOINCREMENT,
4447
customer_id INTEGER NOT NULL,
4548
amount DECIMAL(10, 2) NOT NULL,
4649
order_date DATE NOT NULL,
4750
FOREIGN KEY (customer_id) REFERENCES customers(id)
4851
)
49-
""")
52+
"""
53+
)
5054
)
5155

5256
# Insert test data
5357
await conn.execute(
54-
text("""
58+
text(
59+
"""
5560
INSERT INTO customers (name, email, state) VALUES
5661
('Alice', '[email protected]', 'California'),
5762
('Bob', '[email protected]', 'New York'),
5863
('Charlie', '[email protected]', 'California')
59-
""")
64+
"""
65+
)
6066
)
6167

6268
await conn.execute(
63-
text("""
69+
text(
70+
"""
6471
INSERT INTO orders (customer_id, amount, order_date) VALUES
6572
(1, 100.50, '2024-01-15'),
6673
(1, 200.00, '2024-02-20'),
6774
(2, 150.75, '2024-01-20'),
6875
(3, 75.25, '2024-03-01')
69-
""")
76+
"""
77+
)
7078
)
7179

7280
yield engine
@@ -356,13 +364,15 @@ async def test_join_query(self, test_session: AsyncSession) -> None:
356364
"""Test JOIN query."""
357365
executor = SafeQueryExecutor(test_session)
358366

359-
result = await executor.execute("""
367+
result = await executor.execute(
368+
"""
360369
SELECT c.name, SUM(o.amount) as total_orders
361370
FROM customers c
362371
JOIN orders o ON c.id = o.customer_id
363372
GROUP BY c.id
364373
ORDER BY total_orders DESC
365-
""")
374+
"""
375+
)
366376

367377
assert result.success is True
368378
assert result.row_count == 3
@@ -376,7 +386,8 @@ async def test_cte_query(self, test_session: AsyncSession) -> None:
376386
"""Test Common Table Expression (CTE) query."""
377387
executor = SafeQueryExecutor(test_session)
378388

379-
result = await executor.execute("""
389+
result = await executor.execute(
390+
"""
380391
WITH customer_totals AS (
381392
SELECT customer_id, SUM(amount) as total
382393
FROM orders
@@ -385,7 +396,8 @@ async def test_cte_query(self, test_session: AsyncSession) -> None:
385396
SELECT c.name, ct.total
386397
FROM customers c
387398
JOIN customer_totals ct ON c.id = ct.customer_id
388-
""")
399+
"""
400+
)
389401

390402
assert result.success is True
391403
assert result.row_count == 3
@@ -468,4 +480,3 @@ async def test_schema_to_query_flow(self, test_engine: AsyncEngine) -> None:
468480
for row in result.rows:
469481
assert "name" in row
470482
assert "order_count" in row
471-

tests/unit/test_connection.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ def reset_global_manager(self) -> None:
219219
db.connection._db_manager = None
220220

221221
@pytest.mark.asyncio
222-
async def test_get_database_creates_manager(
223-
self, mock_settings: MagicMock
224-
) -> None:
222+
async def test_get_database_creates_manager(self, mock_settings: MagicMock) -> None:
225223
"""Test get_database creates and initializes manager."""
226224
with patch("db.connection.get_settings", return_value=mock_settings):
227225
with patch("db.connection.create_async_engine") as mock_engine:
@@ -267,4 +265,3 @@ async def test_close_database_when_not_initialized(self) -> None:
267265
"""Test close_database when no manager exists."""
268266
# Should not raise any errors
269267
await close_database()
270-

tests/unit/test_executor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ async def test_execute_explain_invalid_query(self, mock_session: MagicMock) -> N
326326
@pytest.mark.asyncio
327327
async def test_execute_explain_failure(self, mock_session: MagicMock) -> None:
328328
"""Test EXPLAIN failure returns error info."""
329-
mock_session.execute = AsyncMock(
330-
side_effect=Exception("EXPLAIN not supported")
331-
)
329+
mock_session.execute = AsyncMock(side_effect=Exception("EXPLAIN not supported"))
332330

333331
executor = SafeQueryExecutor(mock_session)
334332
result = await executor.execute_explain("SELECT * FROM users")
@@ -405,4 +403,3 @@ def test_injection_patterns_coverage(self) -> None:
405403

406404
for pattern in INJECTION_PATTERNS:
407405
re.compile(pattern) # Should not raise
408-

tests/unit/test_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,3 @@ async def test_get_sample_data_error(self) -> None:
434434

435435
# Should return empty list on error
436436
assert result == []
437-

0 commit comments

Comments
 (0)