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 )
| 61 | |
| 62 | |
| 63 | def 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 | |
| 80 | def MockAsyncServerResponseInProgress(): |