From 3ec5e8ecbea591cc0a6d68d28b69833944a8a422 Mon Sep 17 00:00:00 2001 From: Gitbot Date: Thu, 17 Aug 2023 17:39:07 +0000 Subject: [PATCH] Automated autopep8 fixes --- nanome/beta/__init__.py | 2 +- testing/unit/test_beta/test_plugin_server.py | 7 ++-- .../unit/test_beta/test_redis_interface.py | 37 ++++++++++--------- testing/unit/test_beta/test_session_client.py | 17 ++++----- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/nanome/beta/__init__.py b/nanome/beta/__init__.py index 21b50dfa..1f26f573 100644 --- a/nanome/beta/__init__.py +++ b/nanome/beta/__init__.py @@ -1 +1 @@ -from .redis_interface import PluginInstanceRedisInterface, StreamRedisInterface # noqa: E402 \ No newline at end of file +from .redis_interface import PluginInstanceRedisInterface, StreamRedisInterface # noqa: E402 diff --git a/testing/unit/test_beta/test_plugin_server.py b/testing/unit/test_beta/test_plugin_server.py index 47324712..b185f9dc 100644 --- a/testing/unit/test_beta/test_plugin_server.py +++ b/testing/unit/test_beta/test_plugin_server.py @@ -58,7 +58,7 @@ def test_keep_alive(self) -> None: @patch.object(PluginServer, "route_bytes", new_callable=AsyncMock) def test_poll_nts(self, route_bytes_mock): self.server.nts_reader = MagicMock() - + packed_packet = self.packet.pack() header_fut = asyncio.Future() header_fut.set_result(packed_packet[:Packet.packet_header_length]) @@ -86,14 +86,15 @@ def test_connect_plugin(self, mock_header_unpack): self.server.nts_writer.drain = AsyncMock() self.server.nts_reader = MagicMock() self.server.nts_reader.readexactly = AsyncMock() - + mock_header_unpack.return_value = [0, 0, 0, "test_plugin_id", 0] plugin_id = asyncio.run(self.server.connect_plugin("name", "description")) - + self.assertEqual(plugin_id, "test_plugin_id") # Add more test methods as necessary + if __name__ == "__main__": unittest.main() diff --git a/testing/unit/test_beta/test_redis_interface.py b/testing/unit/test_beta/test_redis_interface.py index 09999fa0..c1a592f2 100644 --- a/testing/unit/test_beta/test_redis_interface.py +++ b/testing/unit/test_beta/test_redis_interface.py @@ -4,6 +4,7 @@ from nanome.beta.redis_interface import StreamRedisInterface, PluginInstanceRedisInterface from nanome.util import enums, Color + class TestStreamRedisInterface(unittest.TestCase): def setUp(self): self.mock_plugin_interface = Mock() @@ -50,8 +51,8 @@ def test_rpc_request(self): # You might need to expand on it depending on the specifics of your application. function_name = 'request_complex_list' with patch('json.dumps', return_value='json_string'), \ - patch('time.time', side_effect=[0, 1, 2, 31]), \ - patch.object(self.redis_interface, 'redis'): + patch('time.time', side_effect=[0, 1, 2, 31]), \ + patch.object(self.redis_interface, 'redis'): mock_pubsub = Mock() mock_pubsub.get_message.return_value = {'type': 'message', 'data': b'[]'} mock_pubsub.channels.keys.return_value = [b'channel'] @@ -61,7 +62,7 @@ def test_rpc_request(self): # Verify interaction with Redis, etc. self.redis_interface.redis.publish.assert_called_once_with('channel', 'json_string') - + def test_request_complex_list(self): fn_name = 'request_complex_list' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -70,7 +71,7 @@ def test_request_complex_list(self): response = self.redis_interface.request_complex_list() self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_upload_shapes(self): fn_name = 'upload_shapes' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -91,7 +92,7 @@ def test_stream_update(self): response = self.redis_interface.stream_update(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_get_plugin_data(self): fn_name = 'get_plugin_data' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -99,7 +100,7 @@ def test_get_plugin_data(self): response = self.redis_interface.get_plugin_data() self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name) - + def test_request_workspace(self): fn_name = 'request_workspace' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -107,7 +108,7 @@ def test_request_workspace(self): response = self.redis_interface.request_workspace() self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=[]) - + def test_request_complexes(self): fn_name = 'request_complexes' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -117,7 +118,7 @@ def test_request_complexes(self): response = self.redis_interface.request_complexes(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_update_structures_shallow(self): fn_name = 'update_structures_shallow' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -127,7 +128,7 @@ def test_update_structures_shallow(self): response = self.redis_interface.update_structures_shallow(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_update_structures_deep(self): fn_name = 'update_structures_deep' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -137,7 +138,7 @@ def test_update_structures_deep(self): response = self.redis_interface.update_structures_deep(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_update_workspace(self): fn_name = 'update_workspace' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -157,7 +158,7 @@ def test_zoom_on_structures(self): response = self.redis_interface.zoom_on_structures(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_center_on_structures(self): fn_name = 'center_on_structures' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -167,7 +168,7 @@ def test_center_on_structures(self): response = self.redis_interface.center_on_structures(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_add_to_workspace(self): fn_name = 'add_to_workspace' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -177,7 +178,7 @@ def test_add_to_workspace(self): response = self.redis_interface.add_to_workspace(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_add_bonds(self): fn_name = 'add_bonds' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -187,7 +188,7 @@ def test_add_bonds(self): response = self.redis_interface.add_bonds(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_open_url(self): fn_name = 'open_url' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -197,7 +198,7 @@ def test_open_url(self): response = self.redis_interface.open_url(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_request_presenter_info(self): fn_name = 'request_presenter_info' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -206,7 +207,7 @@ def test_request_presenter_info(self): response = self.redis_interface.request_presenter_info(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_request_controller_transforms(self): fn_name = 'request_controller_transforms' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -215,7 +216,7 @@ def test_request_controller_transforms(self): response = self.redis_interface.request_controller_transforms(*args) self.assertIsNotNone(response) mock_rpc_request.assert_called_once_with(fn_name, args=args) - + def test_apply_color_scheme(self): fn_name = 'apply_color_scheme' with patch.object(self.redis_interface, '_rpc_request') as mock_rpc_request: @@ -226,4 +227,4 @@ def test_apply_color_scheme(self): mock_rpc_request.return_value = [] response = self.redis_interface.apply_color_scheme(*args) self.assertIsNotNone(response) - mock_rpc_request.assert_called_once_with(fn_name, args=args) \ No newline at end of file + mock_rpc_request.assert_called_once_with(fn_name, args=args) diff --git a/testing/unit/test_beta/test_session_client.py b/testing/unit/test_beta/test_session_client.py index b2e6700d..e450b36a 100644 --- a/testing/unit/test_beta/test_session_client.py +++ b/testing/unit/test_beta/test_session_client.py @@ -21,12 +21,11 @@ def setUpClass(cls): cls.version_table = json.load(f) cls.plugin_id = 21 cls.session_id = 42 - def setUp(self): self.client = SessionClient(self.plugin_id, self.session_id, self.version_table) self.client.writer = MagicMock() - + # Mock request futs self.request_id = 1 response_fut = asyncio.Future() @@ -51,14 +50,14 @@ def test_update_menu(self): expects_response = False self.client.update_menu(menu, shallow=shallow) mock_send_message.assert_called_once_with(Messages.menu_update, [menu, True], expects_response) - + async def test_request_complex_list(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id expects_response = True await self.client.request_complex_list() mock_send_message.assert_called_once_with(Messages.complex_list_request, None, expects_response) - + async def test_request_workspace(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id @@ -73,7 +72,7 @@ async def test_request_complexes(self): expects_response = True await self.client.request_complexes(comp_indices) mock_send_message.assert_called_once_with(Messages.complexes_request, comp_indices, expects_response) - + def test_update_workspace(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id @@ -81,7 +80,7 @@ def test_update_workspace(self): expects_response = False self.client.update_workspace(workspace) mock_send_message.assert_called_once_with(Messages.workspace_update, [workspace], expects_response) - + async def test_send_notification(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id @@ -90,7 +89,7 @@ async def test_send_notification(self): expects_response = False await self.client.send_notification(notification_type, message) mock_send_message.assert_called_once_with(Messages.notification_send, [notification_type, message], expects_response) - + async def test_update_structures_deep(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id @@ -108,7 +107,7 @@ def test_update_structures_shallow(self): expects_response = True self.client.update_structures_shallow([atom, comp]) mock_send_message.assert_called_once_with(Messages.structures_shallow_update, [atom, comp], expects_response) - + def test_zoom_on_structures(self): with patch.object(self.client, '_send_message') as mock_send_message: mock_send_message.return_value = self.request_id @@ -156,5 +155,3 @@ def test_update_node(self): expects_response = False self.client.update_node(ln) mock_send_message.assert_called_once_with(Messages.node_update, (ln,), expects_response) - - \ No newline at end of file