From 30904671861a3f4e5aec6cc7d42ca0b4b45d03f2 Mon Sep 17 00:00:00 2001 From: cadea Date: Mon, 4 Mar 2024 14:57:49 -0600 Subject: [PATCH] Organizing issues with branch conflict. --- tests/test_fractal_async_client.py | 82 ------------------------------ 1 file changed, 82 deletions(-) delete mode 100644 tests/test_fractal_async_client.py diff --git a/tests/test_fractal_async_client.py b/tests/test_fractal_async_client.py deleted file mode 100644 index 62e5492..0000000 --- a/tests/test_fractal_async_client.py +++ /dev/null @@ -1,82 +0,0 @@ -from unittest.mock import AsyncMock, MagicMock, patch - -from fractal.matrix.async_client import FractalAsyncClient, RoomSendResponse -from nio import RoomSendError - - -async def test_send_message_contains_bytes(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.return_value = MagicMock(spec=RoomSendResponse) - room = "test_room" - test_bytes = b"test_message" - await test_fractal_client.send_message(room=room, message=test_bytes) - expected_argument = {"msgtype": "taskiq.task", "body": "test_message"} - mock_room_send.assert_called_with(room, "taskiq.task", expected_argument) - - -async def test_send_message_contains_string(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.return_value = MagicMock(spec=RoomSendResponse) - room = "test_room" - test_string = "test_string" - await test_fractal_client.send_message(room=room, message=test_string) - expected_argument = {"msgtype": "taskiq.task", "body": "test_string"} - mock_room_send.assert_called_with(room, "taskiq.task", expected_argument) - - -async def test_send_message_contains_list(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.return_value = MagicMock(spec=RoomSendResponse) - room = "test_room" - test_list = ["testlist"] - await test_fractal_client.send_message(room=room, message=test_list) - expected_argument = {"msgtype": "taskiq.task", "body": test_list} - mock_room_send.assert_called_with(room, "taskiq.task", expected_argument) - - -async def test_send_message_contains_dictionary(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.return_value = MagicMock(spec=RoomSendResponse) - room = "test_room" - test_dic = {"val": "1"} - await test_fractal_client.send_message(room=room, message=test_dic) - expected_argument = {"msgtype": "taskiq.task", "body": test_dic} - mock_room_send.assert_called_with(room, "taskiq.task", expected_argument) - - -async def test_send_message_returns_error(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.return_value = RoomSendError(message="Test Error Message") - with patch("fractal.matrix.async_client.logger") as mock_logger: - room = "test_room" - test_dic = {"val": "1"} - await test_fractal_client.send_message(room=room, message=test_dic) - mock_logger.error.assert_called_once() - - -async def test_send_message_raises_exception(): - test_fractal_client = FractalAsyncClient() - with patch( - "fractal.matrix.async_client.FractalAsyncClient.room_send", new=AsyncMock() - ) as mock_room_send: - mock_room_send.side_effect = Exception() - with patch("fractal.matrix.async_client.logger") as mock_logger: - room = "test_room" - test_dic = {"val": "1"} - await test_fractal_client.send_message(room=room, message=test_dic) - mock_logger.error.assert_called_once()