Skip to content

Commit d28e18e

Browse files
committed
Add list episodes tests
1 parent 2975697 commit d28e18e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from unittest.mock import AsyncMock, MagicMock, patch
2+
3+
import pytest
4+
5+
from futuramaapi.routers.services.episodes.list_episodes import ListEpisodesService
6+
7+
8+
@pytest.fixture
9+
def mock_paginate(request):
10+
patcher = patch(
11+
"futuramaapi.routers.services.episodes.list_episodes.paginate",
12+
new_callable=AsyncMock,
13+
)
14+
mocked = patcher.start()
15+
request.addfinalizer(patcher.stop)
16+
return mocked
17+
18+
19+
class TestListEpisodesService:
20+
@pytest.mark.asyncio
21+
async def test_list_episodes_success(
22+
self,
23+
mock_session_manager,
24+
mock_paginate,
25+
):
26+
# Arrange
27+
page = MagicMock()
28+
mock_paginate.return_value = page
29+
30+
service = ListEpisodesService()
31+
32+
# Act
33+
result = await service()
34+
35+
# Assert
36+
assert result is page
37+
mock_paginate.assert_called_once()
38+
39+
args, _ = mock_paginate.call_args
40+
assert args[0] is mock_session_manager

0 commit comments

Comments
 (0)