|
6 | 6 | # pylint: disable=too-many-statements |
7 | 7 |
|
8 | 8 |
|
| 9 | +from collections.abc import Callable |
9 | 10 | from http import HTTPStatus |
10 | 11 | from unittest.mock import MagicMock |
11 | 12 |
|
|
32 | 33 |
|
33 | 34 |
|
34 | 35 | @pytest.fixture |
35 | | -def mocked_notify_conversation_message_created( |
36 | | - mocker: MockerFixture, |
37 | | -) -> MagicMock: |
38 | | - return mocker.patch.object( |
39 | | - simcore_service_webserver.conversations._conversation_message_service, |
40 | | - "notify_conversation_message_created", |
41 | | - ) |
| 36 | +def mock_notify_function(mocker: MockerFixture) -> Callable[[str], MagicMock]: |
| 37 | + def _mock(function_name: str) -> MagicMock: |
| 38 | + return mocker.patch.object( |
| 39 | + simcore_service_webserver.conversations._conversation_message_service, |
| 40 | + function_name, |
| 41 | + ) |
42 | 42 |
|
43 | | - |
44 | | -@pytest.fixture |
45 | | -def mocked_notify_conversation_message_updated( |
46 | | - mocker: MockerFixture, |
47 | | -) -> MagicMock: |
48 | | - return mocker.patch.object( |
49 | | - simcore_service_webserver.conversations._conversation_message_service, |
50 | | - "notify_conversation_message_updated", |
51 | | - ) |
52 | | - |
53 | | - |
54 | | -@pytest.fixture |
55 | | -def mocked_notify_conversation_message_deleted( |
56 | | - mocker: MockerFixture, |
57 | | -) -> MagicMock: |
58 | | - return mocker.patch.object( |
59 | | - simcore_service_webserver.conversations._conversation_message_service, |
60 | | - "notify_conversation_message_deleted", |
61 | | - ) |
| 43 | + return _mock |
62 | 44 |
|
63 | 45 |
|
64 | 46 | @pytest.mark.parametrize( |
@@ -196,10 +178,18 @@ async def test_project_conversation_messages_full_workflow( |
196 | 178 | user_project: ProjectDict, |
197 | 179 | expected: HTTPStatus, |
198 | 180 | postgres_db: sa.engine.Engine, |
199 | | - mocked_notify_conversation_message_created: MagicMock, |
200 | | - mocked_notify_conversation_message_updated: MagicMock, |
201 | | - mocked_notify_conversation_message_deleted: MagicMock, |
| 181 | + mock_notify_function: Callable[[str], MagicMock], |
202 | 182 | ): |
| 183 | + mocked_notify_conversation_message_created = mock_notify_function( |
| 184 | + "notify_conversation_message_created" |
| 185 | + ) |
| 186 | + mocked_notify_conversation_message_updated = mock_notify_function( |
| 187 | + "notify_conversation_message_updated" |
| 188 | + ) |
| 189 | + mocked_notify_conversation_message_deleted = mock_notify_function( |
| 190 | + "notify_conversation_message_deleted" |
| 191 | + ) |
| 192 | + |
203 | 193 | base_project_url = client.app.router["list_project_conversations"].url_for( |
204 | 194 | project_id=user_project["uuid"] |
205 | 195 | ) |
|
0 commit comments