|
7 | 7 | from hikari.impl import RESTClientImpl |
8 | 8 |
|
9 | 9 | from src import bot |
10 | | -from src.tests.conftest import RestClientContextManagerMock |
| 10 | +from src.tests.conftest import MockShelf, RestClientContextManagerMock |
11 | 11 | from src.utils.data_types import SimpleProjectItemEvent |
12 | 12 | from src.utils.error import ForumChannelNotFound |
13 | 13 |
|
14 | 14 |
|
| 15 | +@patch("shelve.open") |
15 | 16 | @patch("src.bot.fetch_item_name", new_callable=AsyncMock) |
16 | 17 | @patch.object(RESTClientImpl, "create_forum_post", new_callable=AsyncMock) |
17 | 18 | async def test_create_post( |
18 | 19 | mock_create_forum_post, |
19 | 20 | mock_fetch_item_name, |
| 21 | + mock_shelve_open, |
20 | 22 | rest_client_mock, |
21 | 23 | shared_forum_channel_mock, |
22 | 24 | user_text_mention, |
| 25 | + post_mock, |
23 | 26 | ): |
24 | 27 | mock_fetch_item_name.return_value = "audacity4" |
| 28 | + mock_shelf = MockShelf() |
| 29 | + mock_shelve_open.return_value = mock_shelf |
| 30 | + mock_create_forum_post.return_value = post_mock |
25 | 31 | message = f"Nowy task stworzony audacity4 przez: {user_text_mention}.\n Link do taska: https://github.com/orgs/my-org/projects/1?pane=issue&item_id=1" |
26 | 32 | event = SimpleProjectItemEvent(1, "audacity4", "norbiros", "created") |
27 | 33 | await bot.create_post(event, user_text_mention, shared_forum_channel_mock, rest_client_mock, []) |
28 | 34 | mock_create_forum_post.assert_called_with( |
29 | 35 | shared_forum_channel_mock.forum_channel, event.node_id, message, auto_archive_duration=10080, user_mentions=[] |
30 | 36 | ) |
| 37 | + assert mock_shelf.get("audacity4") == "621" |
31 | 38 |
|
32 | 39 |
|
33 | 40 | @patch("src.bot.create_post", new_callable=AsyncMock) |
|
0 commit comments