MCPcopy Create free account
hub / github.com/ycm-core/YouCompleteMe / MockAsyncServerResponseDone

Function MockAsyncServerResponseDone

python/ycm/tests/mock_utils.py:63–77  ·  view source on GitHub ↗

Return a MessagePoll containing a fake future object that is complete with the supplied response message. Suitable for mocking a response future within a client request. For example: with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 1 ) ) as v: mock_response = MockAsyncSer

( response )

Source from the content-addressed store, hash-verified

61
62
63def MockAsyncServerResponseDone( response ):
64 """Return a MessagePoll containing a fake future object that is complete with
65 the supplied response message. Suitable for mocking a response future within
66 a client request. For example:
67
68 with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 1 ) ) as v:
69 mock_response = MockAsyncServerResponseDone( response )
70 with patch.dict( ycm._message_poll_requests, {} ):
71 ycm._message_poll_requests[ filetype ] = MessagesPoll( v.current.buffer )
72 ycm._message_poll_requests[ filetype ]._response_future = mock_response
73 # Needed to keep a reference to the mocked dictionary
74 mock_future = ycm._message_poll_requests[ filetype ]._response_future
75 ycm.OnPeriodicTick() # Uses ycm._message_poll_requests[ filetype ] ...
76 """
77 return mock.MagicMock( wraps = FakeFuture( True, response ) )
78
79
80def MockAsyncServerResponseInProgress():

Calls 1

FakeFutureClass · 0.85