Resolve "Renvoyer l'alerte quand on reçoit une RoomSendError"

This commit is contained in:
HgO 2022-11-25 18:59:32 +00:00
parent a2ba654a77
commit fbbd66edd7
3 changed files with 10 additions and 8 deletions

View file

@ -77,7 +77,7 @@ async def send_text_to_room(
)
if isinstance(response_event, RoomSendError):
raise SendRetryError(response_event.error)
raise SendRetryError(f"{response_event.status_code} - {response_event.message}")
return response_event
@ -120,7 +120,7 @@ async def react_to_event(
)
if isinstance(response_event, RoomSendError):
raise SendRetryError(response_event.error)
raise SendRetryError(f"{response_event.status_code} - {response_event.message}")
return response_event

View file

@ -36,16 +36,16 @@ def create_matrix_client(config: Config) -> AsyncClient:
# Configuration options for the AsyncClient
try:
matrix_client_config = AsyncClientConfig(
max_limit_exceeded=0,
max_timeouts=0,
max_limit_exceeded=5,
max_timeouts=3,
store_sync_tokens=True,
encryption_enabled=True,
)
except ImportWarning as e:
logger.warning(e)
matrix_client_config = AsyncClientConfig(
max_limit_exceeded=0,
max_timeouts=0,
max_limit_exceeded=5,
max_timeouts=3,
store_sync_tokens=True,
encryption_enabled=False,
)

View file

@ -64,7 +64,8 @@ class ChatFunctionsTestCase(unittest.IsolatedAsyncioTestCase):
async def test_react_to_event_return_room_send_error(self) -> None:
fake_response = Mock(spec=nio.RoomSendError)
fake_response.error = "some error"
fake_response.message = "some error"
fake_response.status_code = "some status code"
fake_matrix_client = Mock(spec=nio.AsyncClient)
fake_matrix_client.room_send.return_value = make_awaitable(fake_response)
fake_room_id = "!abcdefgh:example.com"
@ -204,7 +205,8 @@ class ChatFunctionsTestCase(unittest.IsolatedAsyncioTestCase):
async def test_send_text_to_room_return_room_send_error(self) -> None:
fake_response = Mock(spec=nio.RoomSendError)
fake_response.error = "some error"
fake_response.status_code = "some status_code"
fake_response.message = "some error"
fake_matrix_client = Mock(spec=nio.AsyncClient)
fake_matrix_client.room_send.return_value = make_awaitable(fake_response)
fake_room_id = "!abcdefgh:example.com"