66from rayforce .types import Table
77from rayforce import errors
88from rayforce .ffi import FFI
9- from rayforce .utils .ipc import (
9+ from rayforce .network .ipc import (
1010 IPCConnection ,
1111 IPCClient ,
1212 IPCServer ,
@@ -44,11 +44,11 @@ def mock_handle(self):
4444
4545 @pytest .fixture
4646 def connection (self , mock_engine , mock_handle ):
47- with patch ("rayforce.utils .ipc.FFI.get_obj_type" , return_value = r .TYPE_I64 ):
47+ with patch ("rayforce.network .ipc.FFI.get_obj_type" , return_value = r .TYPE_I64 ):
4848 return IPCConnection (engine = mock_engine , handle = mock_handle )
4949
50- @patch ("rayforce.utils .ipc.FFI.write" )
51- @patch ("rayforce.utils .ipc.ray_to_python" )
50+ @patch ("rayforce.network .ipc.FFI.write" )
51+ @patch ("rayforce.network .ipc.ray_to_python" )
5252 def test_execute (self , mock_ray_to_python , mock_write , connection ):
5353 mock_write .return_value = MagicMock ()
5454 mock_ray_to_python .return_value = "result"
@@ -63,7 +63,7 @@ def test_execute_closed(self, connection):
6363 with pytest .raises (errors .RayforceIPCError , match = "Cannot write to closed connection" ):
6464 connection .execute ("test_query" )
6565
66- @patch ("rayforce.utils .ipc.FFI.hclose" )
66+ @patch ("rayforce.network .ipc.FFI.hclose" )
6767 def test_close_removes_from_pool (self , mock_hclose , mock_engine , mock_handle ):
6868 conn = IPCConnection (engine = mock_engine , handle = mock_handle )
6969 conn_id = id (conn )
@@ -74,7 +74,7 @@ def test_close_removes_from_pool(self, mock_hclose, mock_engine, mock_handle):
7474 assert conn ._closed is True
7575 mock_hclose .assert_called_once_with (conn .handle )
7676
77- @patch ("rayforce.utils .ipc.FFI.hclose" )
77+ @patch ("rayforce.network .ipc.FFI.hclose" )
7878 def test_close_idempotent (self , mock_hclose , connection ):
7979 connection .close ()
8080 connection .close ()
@@ -92,8 +92,8 @@ class TestIPCEngine:
9292 def engine (self ):
9393 return IPCClient (host = "localhost" , port = 5000 )
9494
95- @patch ("rayforce.utils .ipc.FFI.get_obj_type" )
96- @patch ("rayforce.utils .ipc.FFI.hopen" )
95+ @patch ("rayforce.network .ipc.FFI.get_obj_type" )
96+ @patch ("rayforce.network .ipc.FFI.hopen" )
9797 def test_acquire_success (self , mock_hopen , mock_get_obj_type , engine ):
9898 mock_handle = MagicMock (spec = r .RayObject )
9999
@@ -111,9 +111,9 @@ def get_obj_type_side_effect(obj):
111111 assert conn .handle == mock_handle
112112 assert id (conn ) in engine .pool
113113
114- @patch ("rayforce.utils .ipc.FFI.get_obj_type" )
115- @patch ("rayforce.utils .ipc.FFI.hopen" )
116- @patch ("rayforce.utils .ipc.FFI.get_error_obj" )
114+ @patch ("rayforce.network .ipc.FFI.get_obj_type" )
115+ @patch ("rayforce.network .ipc.FFI.hopen" )
116+ @patch ("rayforce.network .ipc.FFI.get_error_obj" )
117117 def test_acquire_failure (self , mock_get_error , mock_hopen , mock_get_obj_type , engine ):
118118 mock_error = MagicMock (spec = r .RayObject )
119119
@@ -129,8 +129,8 @@ def get_obj_type_side_effect(obj):
129129 with pytest .raises (errors .RayforceIPCError , match = "Error when establishing connection" ):
130130 engine .acquire ()
131131
132- @patch ("rayforce.utils .ipc.FFI.get_obj_type" )
133- @patch ("rayforce.utils .ipc.FFI.hopen" )
132+ @patch ("rayforce.network .ipc.FFI.get_obj_type" )
133+ @patch ("rayforce.network .ipc.FFI.hopen" )
134134 def test_dispose_connections (self , mock_hopen , mock_get_obj_type , engine ):
135135 mock_handle1 = MagicMock (spec = r .RayObject )
136136 mock_handle2 = MagicMock (spec = r .RayObject )
@@ -174,8 +174,8 @@ def test_init_invalid_port_too_low(self, port):
174174 with pytest .raises (errors .RayforceIPCError , match = "Invalid port number" ):
175175 IPCServer (port = port )
176176
177- @patch ("rayforce.utils .ipc.FFI.ipc_listen" )
178- @patch ("rayforce.utils .ipc.FFI.runtime_run" )
177+ @patch ("rayforce.network .ipc.FFI.ipc_listen" )
178+ @patch ("rayforce.network .ipc.FFI.runtime_run" )
179179 def test_listen_success (self , mock_runtime_run , mock_ipc_listen , server ):
180180 mock_ipc_listen .return_value = 123
181181 mock_runtime_run .return_value = 0
@@ -186,9 +186,9 @@ def test_listen_success(self, mock_runtime_run, mock_ipc_listen, server):
186186 assert server ._listener_id == 123
187187 mock_runtime_run .assert_called_once ()
188188
189- @patch ("rayforce.utils .ipc.FFI.ipc_listen" )
190- @patch ("rayforce.utils .ipc.FFI.runtime_run" )
191- @patch ("rayforce.utils .ipc.FFI.ipc_close_listener" )
189+ @patch ("rayforce.network .ipc.FFI.ipc_listen" )
190+ @patch ("rayforce.network .ipc.FFI.runtime_run" )
191+ @patch ("rayforce.network .ipc.FFI.ipc_close_listener" )
192192 def test_listen_closes_on_exception (
193193 self , mock_close , mock_runtime_run , mock_ipc_listen , server
194194 ):
@@ -202,9 +202,9 @@ def test_listen_closes_on_exception(
202202 mock_close .assert_called_once_with (123 )
203203 assert server ._listener_id is None
204204
205- @patch ("rayforce.utils .ipc.FFI.ipc_listen" )
206- @patch ("rayforce.utils .ipc.FFI.runtime_run" )
207- @patch ("rayforce.utils .ipc.FFI.ipc_close_listener" )
205+ @patch ("rayforce.network .ipc.FFI.ipc_listen" )
206+ @patch ("rayforce.network .ipc.FFI.runtime_run" )
207+ @patch ("rayforce.network .ipc.FFI.ipc_close_listener" )
208208 def test_listen_closes_on_keyboard_interrupt (
209209 self , mock_close , mock_runtime_run , mock_ipc_listen , server
210210 ):
@@ -238,7 +238,7 @@ def mock_handle(self):
238238
239239 @pytest .fixture
240240 def connection (self , mock_engine , mock_handle ):
241- with patch ("rayforce.utils .ipc.FFI.get_obj_type" , return_value = r .TYPE_I64 ):
241+ with patch ("rayforce.network .ipc.FFI.get_obj_type" , return_value = r .TYPE_I64 ):
242242 return IPCConnection (engine = mock_engine , handle = mock_handle )
243243
244244 def _capture_and_eval (self , connection , query_obj ):
@@ -250,8 +250,8 @@ def capture_write(handle, data):
250250 mock_result = MagicMock (spec = r .RayObject )
251251 return mock_result
252252
253- with patch ("rayforce.utils .ipc.FFI.write" , side_effect = capture_write ):
254- with patch ("rayforce.utils .ipc.ray_to_python" , return_value = "mocked_result" ):
253+ with patch ("rayforce.network .ipc.FFI.write" , side_effect = capture_write ):
254+ with patch ("rayforce.network .ipc.ray_to_python" , return_value = "mocked_result" ):
255255 connection .execute (query_obj )
256256
257257 assert captured_obj is not None
0 commit comments