Skip to content

Commit 607cb02

Browse files
style: apply black formatting to tests and alembic env
1 parent 787ef94 commit 607cb02

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

alembic/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def run_migrations_offline() -> None:
4141

4242
from typing import Any
4343

44+
4445
def do_run_migrations(connection: Any) -> None:
4546
"""Run migrations with connection."""
4647
context.configure(connection=connection, target_metadata=target_metadata)

tests/unit/test_content_service_extended.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
from app.schemas.guide import GuideCreate
1111
from app.services.content import content_service
1212

13+
1314
@pytest.mark.asyncio()
1415
async def test_get_topics_filtering() -> None:
1516
"""Test that topics are filtered by client."""
1617
mock_session = AsyncMock()
1718
client = Client(id=uuid4())
18-
19+
1920
# Mock execute result
2021
mock_result = MagicMock()
2122
mock_result.scalars().all.return_value = [Topic(id=uuid4(), name="T1")]
@@ -24,50 +25,52 @@ async def test_get_topics_filtering() -> None:
2425
topics = await content_service.get_topics(mock_session, client)
2526
assert len(topics) == 1
2627
assert topics[0].name == "T1"
27-
28+
2829
# Verify the query construction (indirectly via coverage of lines)
2930

31+
3032
@pytest.mark.asyncio()
3133
async def test_create_guide_success() -> None:
3234
"""Test successful guide creation."""
3335
mock_session = AsyncMock()
3436
client = Client(id=uuid4())
3537
topic_id = uuid4()
3638
topic = Topic(id=topic_id, client_id=client.id)
37-
39+
3840
guide_in = GuideCreate(
39-
title="Guide 1",
40-
slug="guide-1",
41+
title="Guide 1",
42+
slug="guide-1",
4143
topic_id=topic_id,
4244
content="Simple content",
43-
complexity_level=ComplexityLevel.BEGINNER
45+
complexity_level=ComplexityLevel.BEGINNER,
4446
)
4547

4648
# We need to mock get_topic to succeed (it checks access)
4749
with patch.object(content_service, "get_topic", return_value=topic) as mock_get_topic:
4850
with patch("app.services.content.guide_repo.get_by_slug", return_value=None):
4951
mock_session.add = MagicMock()
50-
52+
5153
result = await content_service.create_guide(mock_session, client, guide_in)
52-
54+
5355
assert result.title == "Guide 1"
5456
assert result.client_id == client.id
5557
mock_get_topic.assert_awaited_once_with(mock_session, client, topic.id)
5658

59+
5760
@pytest.mark.asyncio()
5861
async def test_create_guide_slug_collision() -> None:
5962
"""Test that creating a duplicate slug raises an error."""
6063
mock_session = AsyncMock()
6164
client = Client(id=uuid4())
6265
topic_id = uuid4()
6366
topic = Topic(id=topic_id, client_id=client.id)
64-
67+
6568
guide_in = GuideCreate(
66-
title="Guide 1",
67-
slug="guide-1",
69+
title="Guide 1",
70+
slug="guide-1",
6871
topic_id=topic_id,
6972
content="Simple content",
70-
complexity_level=ComplexityLevel.BEGINNER
73+
complexity_level=ComplexityLevel.BEGINNER,
7174
)
7275

7376
with patch.object(content_service, "get_topic", return_value=topic):
@@ -77,12 +80,13 @@ async def test_create_guide_slug_collision() -> None:
7780
await content_service.create_guide(mock_session, client, guide_in)
7881
assert exc.value.status_code == 400
7982

83+
8084
@pytest.mark.asyncio()
8185
async def test_get_guides_filtering() -> None:
8286
"""Test that guides are filtered by client."""
8387
mock_session = AsyncMock()
8488
client = Client(id=uuid4())
85-
89+
8690
# Mock execute
8791
mock_result = MagicMock()
8892
mock_result.scalars().all.return_value = [Guide(id=uuid4(), title="G1")]
@@ -92,6 +96,7 @@ async def test_get_guides_filtering() -> None:
9296
assert len(guides) == 1
9397
assert guides[0].title == "G1"
9498

99+
95100
@pytest.mark.asyncio()
96101
async def test_get_guide_success() -> None:
97102
"""Test retrieving a guide."""
@@ -104,6 +109,7 @@ async def test_get_guide_success() -> None:
104109
result = await content_service.get_guide(mock_session, client, guide_id)
105110
assert result.id == guide_id
106111

112+
107113
@pytest.mark.asyncio()
108114
async def test_get_guide_forbidden() -> None:
109115
"""Test retrieving a guide belonging to another client."""
@@ -118,6 +124,7 @@ async def test_get_guide_forbidden() -> None:
118124
await content_service.get_guide(mock_session, client, guide_id)
119125
assert exc.value.status_code == 404
120126

127+
121128
@pytest.mark.asyncio()
122129
async def test_get_guide_not_found() -> None:
123130
"""Test retrieving a non-existent guide."""

0 commit comments

Comments
 (0)