|
6 | 6 | import asyncio |
7 | 7 | import re |
8 | 8 | from collections.abc import Awaitable, Callable |
| 9 | +from contextlib import suppress |
9 | 10 | from dataclasses import dataclass, field |
10 | 11 | from datetime import datetime, timedelta |
11 | 12 | from http import HTTPStatus |
|
55 | 56 | from simcore_service_webserver.projects.models import ProjectDict |
56 | 57 | from tenacity import ( |
57 | 58 | AsyncRetrying, |
| 59 | + RetryError, |
58 | 60 | retry_if_exception_type, |
| 61 | + retry_unless_exception_type, |
59 | 62 | stop_after_delay, |
60 | 63 | wait_fixed, |
61 | 64 | ) |
@@ -952,21 +955,29 @@ async def test_stop_node( |
952 | 955 | status.HTTP_202_ACCEPTED if user_role == UserRole.GUEST else expected.accepted, |
953 | 956 | ) |
954 | 957 |
|
955 | | - async for attempt in AsyncRetrying( |
956 | | - wait=wait_fixed(0.1), |
957 | | - stop=stop_after_delay(5), |
958 | | - retry=retry_if_exception_type(AssertionError), |
959 | | - reraise=True, |
960 | | - ): |
961 | | - with attempt: |
962 | | - if error is None: |
| 958 | + if error is None: |
| 959 | + async for attempt in AsyncRetrying( |
| 960 | + wait=wait_fixed(0.1), |
| 961 | + stop=stop_after_delay(5), |
| 962 | + retry=retry_if_exception_type(AssertionError), |
| 963 | + reraise=True, |
| 964 | + ): |
| 965 | + with attempt: |
963 | 966 | mocked_dynamic_services_interface[ |
964 | 967 | "dynamic_scheduler.api.stop_dynamic_service" |
965 | 968 | ].assert_called_once() |
966 | | - else: |
967 | | - mocked_dynamic_services_interface[ |
968 | | - "dynamic_scheduler.api.stop_dynamic_service" |
969 | | - ].assert_not_called() |
| 969 | + else: |
| 970 | + with suppress(RetryError): |
| 971 | + async for attempt in AsyncRetrying( |
| 972 | + wait=wait_fixed(0.1), |
| 973 | + stop=stop_after_delay(5), |
| 974 | + retry=retry_unless_exception_type(AssertionError), |
| 975 | + reraise=True, |
| 976 | + ): |
| 977 | + with attempt: |
| 978 | + mocked_dynamic_services_interface[ |
| 979 | + "dynamic_scheduler.api.stop_dynamic_service" |
| 980 | + ].assert_not_called() |
970 | 981 |
|
971 | 982 |
|
972 | 983 | @pytest.fixture |
|
0 commit comments