File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
tests/unit/routers/services/episodes Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments