Merge branch '8-renvoyer-l-alerte-quand-on-recoit-une-roomsenderror' into 'master'
Resolve "Renvoyer l'alerte quand on reçoit une RoomSendError" Closes #8 See merge request Neutrinet/matrix-alertbot!7
This commit is contained in:
commit
c34a823c35
3 changed files with 10 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue