event_notification_test.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. # coding: utf-8
  2. #
  3. # Copyright (C) 2015-2016 YouCompleteMe contributors
  4. #
  5. # This file is part of YouCompleteMe.
  6. #
  7. # YouCompleteMe is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # YouCompleteMe is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
  19. from __future__ import unicode_literals
  20. from __future__ import print_function
  21. from __future__ import division
  22. from __future__ import absolute_import
  23. # Not installing aliases from python-future; it's unreliable and slow.
  24. from builtins import * # noqa
  25. from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock,
  26. MockVimBuffers, MockVimModule, VimBuffer )
  27. MockVimModule()
  28. import contextlib
  29. import os
  30. from ycm.tests import PathToTestFile, YouCompleteMeInstance, WaitUntilReady
  31. from ycmd.responses import ( BuildDiagnosticData, Diagnostic, Location, Range,
  32. UnknownExtraConf, ServerError )
  33. from hamcrest import ( assert_that, contains, has_entries, has_entry, has_item,
  34. has_items, has_key, is_not )
  35. from mock import call, MagicMock, patch
  36. from nose.tools import eq_, ok_
  37. def PresentDialog_Confirm_Call( message ):
  38. """Return a mock.call object for a call to vimsupport.PresentDialog, as called
  39. why vimsupport.Confirm with the supplied confirmation message"""
  40. return call( message, [ 'Ok', 'Cancel' ] )
  41. def PlaceSign_Call( sign_id, line_num, buffer_num, is_error ):
  42. sign_name = 'YcmError' if is_error else 'YcmWarning'
  43. return call( 'sign place {0} name={1} line={2} buffer={3}'
  44. .format( sign_id, sign_name, line_num, buffer_num ) )
  45. def UnplaceSign_Call( sign_id, buffer_num ):
  46. return call( 'try | exec "sign unplace {0} buffer={1}" |'
  47. ' catch /E158/ | endtry'.format( sign_id, buffer_num ) )
  48. @contextlib.contextmanager
  49. def MockArbitraryBuffer( filetype ):
  50. """Used via the with statement, set up a single buffer with an arbitrary name
  51. and no contents. Its filetype is set to the supplied filetype."""
  52. # Arbitrary, but valid, single buffer open.
  53. current_buffer = VimBuffer( os.path.realpath( 'TEST_BUFFER' ),
  54. window = 1,
  55. filetype = filetype )
  56. with MockVimBuffers( [ current_buffer ], current_buffer ):
  57. yield
  58. @contextlib.contextmanager
  59. def MockEventNotification( response_method, native_filetype_completer = True ):
  60. """Mock out the EventNotification client request object, replacing the
  61. Response handler's JsonFromFuture with the supplied |response_method|.
  62. Additionally mock out YouCompleteMe's FiletypeCompleterExistsForFiletype
  63. method to return the supplied |native_filetype_completer| parameter, rather
  64. than querying the server"""
  65. # We don't want the event to actually be sent to the server, just have it
  66. # return success
  67. with patch( 'ycm.client.event_notification.EventNotification.'
  68. 'PostDataToHandlerAsync',
  69. return_value = MagicMock( return_value=True ) ):
  70. # We set up a fake a Response (as called by EventNotification.Response)
  71. # which calls the supplied callback method. Generally this callback just
  72. # raises an apropriate exception, otherwise it would have to return a mock
  73. # future object.
  74. #
  75. # Note: JsonFromFuture is actually part of ycm.client.base_request, but we
  76. # must patch where an object is looked up, not where it is defined.
  77. # See https://docs.python.org/dev/library/unittest.mock.html#where-to-patch
  78. # for details.
  79. with patch( 'ycm.client.event_notification.JsonFromFuture',
  80. side_effect = response_method ):
  81. # Filetype available information comes from the server, so rather than
  82. # relying on that request, we mock out the check. The caller decides if
  83. # filetype completion is available
  84. with patch(
  85. 'ycm.youcompleteme.YouCompleteMe.FiletypeCompleterExistsForFiletype',
  86. return_value = native_filetype_completer ):
  87. yield
  88. @patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock )
  89. @YouCompleteMeInstance()
  90. def EventNotification_FileReadyToParse_NonDiagnostic_Error_test(
  91. ycm, post_vim_message ):
  92. # This test validates the behaviour of YouCompleteMe.HandleFileParseRequest
  93. # in combination with YouCompleteMe.OnFileReadyToParse when the completer
  94. # raises an exception handling FileReadyToParse event notification
  95. ERROR_TEXT = 'Some completer response text'
  96. def ErrorResponse( *args ):
  97. raise ServerError( ERROR_TEXT )
  98. with MockArbitraryBuffer( 'javascript' ):
  99. with MockEventNotification( ErrorResponse ):
  100. ycm.OnFileReadyToParse()
  101. ok_( ycm.FileParseRequestReady() )
  102. ycm.HandleFileParseRequest()
  103. # The first call raises a warning
  104. post_vim_message.assert_has_exact_calls( [
  105. call( ERROR_TEXT, truncate = True )
  106. ] )
  107. # Subsequent calls don't re-raise the warning
  108. ycm.HandleFileParseRequest()
  109. post_vim_message.assert_has_exact_calls( [
  110. call( ERROR_TEXT, truncate = True )
  111. ] )
  112. # But it does if a subsequent event raises again
  113. ycm.OnFileReadyToParse()
  114. ok_( ycm.FileParseRequestReady() )
  115. ycm.HandleFileParseRequest()
  116. post_vim_message.assert_has_exact_calls( [
  117. call( ERROR_TEXT, truncate = True ),
  118. call( ERROR_TEXT, truncate = True )
  119. ] )
  120. @patch( 'vim.command' )
  121. @YouCompleteMeInstance()
  122. def EventNotification_FileReadyToParse_NonDiagnostic_Error_NonNative_test(
  123. ycm, vim_command ):
  124. with MockArbitraryBuffer( 'javascript' ):
  125. with MockEventNotification( None, False ):
  126. ycm.OnFileReadyToParse()
  127. ycm.HandleFileParseRequest()
  128. vim_command.assert_not_called()
  129. @patch( 'ycm.client.base_request._LoadExtraConfFile',
  130. new_callable = ExtendedMock )
  131. @patch( 'ycm.client.base_request._IgnoreExtraConfFile',
  132. new_callable = ExtendedMock )
  133. @YouCompleteMeInstance()
  134. def EventNotification_FileReadyToParse_NonDiagnostic_ConfirmExtraConf_test(
  135. ycm, ignore_extra_conf, load_extra_conf ):
  136. # This test validates the behaviour of YouCompleteMe.HandleFileParseRequest
  137. # in combination with YouCompleteMe.OnFileReadyToParse when the completer
  138. # raises the (special) UnknownExtraConf exception
  139. FILE_NAME = 'a_file'
  140. MESSAGE = ( 'Found ' + FILE_NAME + '. Load? \n\n(Question can be '
  141. 'turned off with options, see YCM docs)' )
  142. def UnknownExtraConfResponse( *args ):
  143. raise UnknownExtraConf( FILE_NAME )
  144. with MockArbitraryBuffer( 'javascript' ):
  145. with MockEventNotification( UnknownExtraConfResponse ):
  146. # When the user accepts the extra conf, we load it
  147. with patch( 'ycm.vimsupport.PresentDialog',
  148. return_value = 0,
  149. new_callable = ExtendedMock ) as present_dialog:
  150. ycm.OnFileReadyToParse()
  151. ok_( ycm.FileParseRequestReady() )
  152. ycm.HandleFileParseRequest()
  153. present_dialog.assert_has_exact_calls( [
  154. PresentDialog_Confirm_Call( MESSAGE ),
  155. ] )
  156. load_extra_conf.assert_has_exact_calls( [
  157. call( FILE_NAME ),
  158. ] )
  159. # Subsequent calls don't re-raise the warning
  160. ycm.HandleFileParseRequest()
  161. present_dialog.assert_has_exact_calls( [
  162. PresentDialog_Confirm_Call( MESSAGE )
  163. ] )
  164. load_extra_conf.assert_has_exact_calls( [
  165. call( FILE_NAME ),
  166. ] )
  167. # But it does if a subsequent event raises again
  168. ycm.OnFileReadyToParse()
  169. ok_( ycm.FileParseRequestReady() )
  170. ycm.HandleFileParseRequest()
  171. present_dialog.assert_has_exact_calls( [
  172. PresentDialog_Confirm_Call( MESSAGE ),
  173. PresentDialog_Confirm_Call( MESSAGE ),
  174. ] )
  175. load_extra_conf.assert_has_exact_calls( [
  176. call( FILE_NAME ),
  177. call( FILE_NAME ),
  178. ] )
  179. # When the user rejects the extra conf, we reject it
  180. with patch( 'ycm.vimsupport.PresentDialog',
  181. return_value = 1,
  182. new_callable = ExtendedMock ) as present_dialog:
  183. ycm.OnFileReadyToParse()
  184. ok_( ycm.FileParseRequestReady() )
  185. ycm.HandleFileParseRequest()
  186. present_dialog.assert_has_exact_calls( [
  187. PresentDialog_Confirm_Call( MESSAGE ),
  188. ] )
  189. ignore_extra_conf.assert_has_exact_calls( [
  190. call( FILE_NAME ),
  191. ] )
  192. # Subsequent calls don't re-raise the warning
  193. ycm.HandleFileParseRequest()
  194. present_dialog.assert_has_exact_calls( [
  195. PresentDialog_Confirm_Call( MESSAGE )
  196. ] )
  197. ignore_extra_conf.assert_has_exact_calls( [
  198. call( FILE_NAME ),
  199. ] )
  200. # But it does if a subsequent event raises again
  201. ycm.OnFileReadyToParse()
  202. ok_( ycm.FileParseRequestReady() )
  203. ycm.HandleFileParseRequest()
  204. present_dialog.assert_has_exact_calls( [
  205. PresentDialog_Confirm_Call( MESSAGE ),
  206. PresentDialog_Confirm_Call( MESSAGE ),
  207. ] )
  208. ignore_extra_conf.assert_has_exact_calls( [
  209. call( FILE_NAME ),
  210. call( FILE_NAME ),
  211. ] )
  212. @YouCompleteMeInstance()
  213. def EventNotification_FileReadyToParse_Diagnostic_Error_Native_test( ycm ):
  214. _Check_FileReadyToParse_Diagnostic_Error( ycm )
  215. _Check_FileReadyToParse_Diagnostic_Warning( ycm )
  216. _Check_FileReadyToParse_Diagnostic_Clean( ycm )
  217. @patch( 'vim.command' )
  218. def _Check_FileReadyToParse_Diagnostic_Error( ycm, vim_command ):
  219. # Tests Vim sign placement and error/warning count python API
  220. # when one error is returned.
  221. def DiagnosticResponse( *args ):
  222. start = Location( 1, 2, 'TEST_BUFFER' )
  223. end = Location( 1, 4, 'TEST_BUFFER' )
  224. extent = Range( start, end )
  225. diagnostic = Diagnostic( [], start, extent, 'expected ;', 'ERROR' )
  226. return [ BuildDiagnosticData( diagnostic ) ]
  227. with MockArbitraryBuffer( 'cpp' ):
  228. with MockEventNotification( DiagnosticResponse ):
  229. ycm.OnFileReadyToParse()
  230. ok_( ycm.FileParseRequestReady() )
  231. ycm.HandleFileParseRequest()
  232. vim_command.assert_has_calls( [
  233. PlaceSign_Call( 1, 1, 1, True )
  234. ] )
  235. eq_( ycm.GetErrorCount(), 1 )
  236. eq_( ycm.GetWarningCount(), 0 )
  237. # Consequent calls to HandleFileParseRequest shouldn't mess with
  238. # existing diagnostics, when there is no new parse request.
  239. vim_command.reset_mock()
  240. ok_( not ycm.FileParseRequestReady() )
  241. ycm.HandleFileParseRequest()
  242. vim_command.assert_not_called()
  243. eq_( ycm.GetErrorCount(), 1 )
  244. eq_( ycm.GetWarningCount(), 0 )
  245. @patch( 'vim.command' )
  246. def _Check_FileReadyToParse_Diagnostic_Warning( ycm, vim_command ):
  247. # Tests Vim sign placement/unplacement and error/warning count python API
  248. # when one warning is returned.
  249. # Should be called after _Check_FileReadyToParse_Diagnostic_Error
  250. def DiagnosticResponse( *args ):
  251. start = Location( 2, 2, 'TEST_BUFFER' )
  252. end = Location( 2, 4, 'TEST_BUFFER' )
  253. extent = Range( start, end )
  254. diagnostic = Diagnostic( [], start, extent, 'cast', 'WARNING' )
  255. return [ BuildDiagnosticData( diagnostic ) ]
  256. with MockArbitraryBuffer( 'cpp' ):
  257. with MockEventNotification( DiagnosticResponse ):
  258. ycm.OnFileReadyToParse()
  259. ok_( ycm.FileParseRequestReady() )
  260. ycm.HandleFileParseRequest()
  261. vim_command.assert_has_calls( [
  262. PlaceSign_Call( 2, 2, 1, False ),
  263. UnplaceSign_Call( 1, 1 )
  264. ] )
  265. eq_( ycm.GetErrorCount(), 0 )
  266. eq_( ycm.GetWarningCount(), 1 )
  267. # Consequent calls to HandleFileParseRequest shouldn't mess with
  268. # existing diagnostics, when there is no new parse request.
  269. vim_command.reset_mock()
  270. ok_( not ycm.FileParseRequestReady() )
  271. ycm.HandleFileParseRequest()
  272. vim_command.assert_not_called()
  273. eq_( ycm.GetErrorCount(), 0 )
  274. eq_( ycm.GetWarningCount(), 1 )
  275. @patch( 'vim.command' )
  276. def _Check_FileReadyToParse_Diagnostic_Clean( ycm, vim_command ):
  277. # Tests Vim sign unplacement and error/warning count python API
  278. # when there are no errors/warnings left.
  279. # Should be called after _Check_FileReadyToParse_Diagnostic_Warning
  280. with MockArbitraryBuffer( 'cpp' ):
  281. with MockEventNotification( MagicMock( return_value = [] ) ):
  282. ycm.OnFileReadyToParse()
  283. ycm.HandleFileParseRequest()
  284. vim_command.assert_has_calls( [
  285. UnplaceSign_Call( 2, 1 )
  286. ] )
  287. eq_( ycm.GetErrorCount(), 0 )
  288. eq_( ycm.GetWarningCount(), 0 )
  289. @patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
  290. @YouCompleteMeInstance( { 'collect_identifiers_from_tags_files': 1 } )
  291. def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
  292. ycm, *args ):
  293. unicode_dir = PathToTestFile( 'uni¢𐍈d€' )
  294. current_buffer_file = PathToTestFile( 'uni¢𐍈d€', 'current_buffer' )
  295. current_buffer = VimBuffer( name = current_buffer_file,
  296. contents = [ 'current_buffer_contents' ],
  297. filetype = 'some_filetype' )
  298. with patch( 'ycm.client.event_notification.EventNotification.'
  299. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  300. with CurrentWorkingDirectory( unicode_dir ):
  301. with MockVimBuffers( [ current_buffer ], current_buffer, ( 6, 5 ) ):
  302. ycm.OnFileReadyToParse()
  303. assert_that(
  304. # Positional arguments passed to PostDataToHandlerAsync.
  305. post_data_to_handler_async.call_args[ 0 ],
  306. contains(
  307. has_entries( {
  308. 'filepath': current_buffer_file,
  309. 'line_num': 6,
  310. 'column_num': 6,
  311. 'file_data': has_entries( {
  312. current_buffer_file: has_entries( {
  313. 'contents': 'current_buffer_contents\n',
  314. 'filetypes': [ 'some_filetype' ]
  315. } )
  316. } ),
  317. 'event_name': 'FileReadyToParse',
  318. 'tag_files': has_item( PathToTestFile( 'uni¢𐍈d€', 'tags' ) )
  319. } ),
  320. 'event_notification'
  321. )
  322. )
  323. @patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
  324. @YouCompleteMeInstance()
  325. def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test(
  326. ycm, *args ):
  327. current_buffer_file = os.path.realpath( 'current_buffer' )
  328. current_buffer = VimBuffer( name = current_buffer_file,
  329. number = 1,
  330. contents = [ 'current_buffer_contents' ],
  331. filetype = 'some_filetype',
  332. modified = False )
  333. modified_buffer_file = os.path.realpath( 'modified_buffer' )
  334. modified_buffer = VimBuffer( name = modified_buffer_file,
  335. number = 2,
  336. contents = [ 'modified_buffer_contents' ],
  337. filetype = 'some_filetype',
  338. modified = True )
  339. unmodified_buffer_file = os.path.realpath( 'unmodified_buffer' )
  340. unmodified_buffer = VimBuffer( name = unmodified_buffer_file,
  341. number = 3,
  342. contents = [ 'unmodified_buffer_contents' ],
  343. filetype = 'some_filetype',
  344. modified = False )
  345. with patch( 'ycm.client.event_notification.EventNotification.'
  346. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  347. with MockVimBuffers( [ current_buffer, modified_buffer, unmodified_buffer ],
  348. current_buffer,
  349. ( 3, 5 ) ):
  350. ycm.OnBufferVisit()
  351. assert_that(
  352. # Positional arguments passed to PostDataToHandlerAsync.
  353. post_data_to_handler_async.call_args[ 0 ],
  354. contains(
  355. has_entries( {
  356. 'filepath': current_buffer_file,
  357. 'line_num': 3,
  358. 'column_num': 6,
  359. 'file_data': has_entries( {
  360. current_buffer_file: has_entries( {
  361. 'contents': 'current_buffer_contents\n',
  362. 'filetypes': [ 'some_filetype' ]
  363. } ),
  364. modified_buffer_file: has_entries( {
  365. 'contents': 'modified_buffer_contents\n',
  366. 'filetypes': [ 'some_filetype' ]
  367. } )
  368. } ),
  369. 'event_name': 'BufferVisit'
  370. } ),
  371. 'event_notification'
  372. )
  373. )
  374. @YouCompleteMeInstance()
  375. def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test(
  376. ycm ):
  377. current_buffer_file = os.path.realpath( 'current_buffer' )
  378. current_buffer = VimBuffer( name = current_buffer_file,
  379. number = 1,
  380. contents = [ 'current_buffer_contents' ],
  381. filetype = 'some_filetype',
  382. modified = True )
  383. deleted_buffer_file = os.path.realpath( 'deleted_buffer' )
  384. deleted_buffer = VimBuffer( name = deleted_buffer_file,
  385. number = 2,
  386. contents = [ 'deleted_buffer_contents' ],
  387. filetype = 'some_filetype',
  388. modified = False )
  389. with patch( 'ycm.client.event_notification.EventNotification.'
  390. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  391. with MockVimBuffers( [ current_buffer, deleted_buffer ], current_buffer ):
  392. ycm.OnBufferUnload( deleted_buffer_file )
  393. assert_that(
  394. # Positional arguments passed to PostDataToHandlerAsync.
  395. post_data_to_handler_async.call_args[ 0 ],
  396. contains(
  397. has_entries( {
  398. 'filepath': deleted_buffer_file,
  399. 'line_num': 1,
  400. 'column_num': 1,
  401. 'file_data': has_entries( {
  402. current_buffer_file: has_entries( {
  403. 'contents': 'current_buffer_contents\n',
  404. 'filetypes': [ 'some_filetype' ]
  405. } ),
  406. deleted_buffer_file: has_entries( {
  407. 'contents': 'deleted_buffer_contents\n',
  408. 'filetypes': [ 'some_filetype' ]
  409. } )
  410. } ),
  411. 'event_name': 'BufferUnload'
  412. } ),
  413. 'event_notification'
  414. )
  415. )
  416. @patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
  417. return_value = [ 'foo', 'bar' ] )
  418. @YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
  419. def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
  420. ycm, *args ):
  421. current_buffer = VimBuffer( name = 'current_buffer',
  422. filetype = 'some_filetype' )
  423. with patch( 'ycm.client.event_notification.EventNotification.'
  424. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  425. with MockVimBuffers( [ current_buffer ], current_buffer ):
  426. ycm.OnFileReadyToParse()
  427. assert_that(
  428. # Positional arguments passed to PostDataToHandlerAsync.
  429. post_data_to_handler_async.call_args[ 0 ],
  430. contains(
  431. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  432. 'event_notification'
  433. )
  434. )
  435. # Do not send again syntax keywords in subsequent requests.
  436. ycm.OnFileReadyToParse()
  437. assert_that(
  438. # Positional arguments passed to PostDataToHandlerAsync.
  439. post_data_to_handler_async.call_args[ 0 ],
  440. contains(
  441. is_not( has_key( 'syntax_keywords' ) ),
  442. 'event_notification'
  443. )
  444. )
  445. @patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
  446. return_value = [ 'foo', 'bar' ] )
  447. @YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
  448. def EventNotification_FileReadyToParse_SyntaxKeywords_ClearCacheIfRestart_test(
  449. ycm, *args ):
  450. current_buffer = VimBuffer( name = 'current_buffer',
  451. filetype = 'some_filetype' )
  452. with patch( 'ycm.client.event_notification.EventNotification.'
  453. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  454. with MockVimBuffers( [ current_buffer ], current_buffer ):
  455. ycm.OnFileReadyToParse()
  456. assert_that(
  457. # Positional arguments passed to PostDataToHandlerAsync.
  458. post_data_to_handler_async.call_args[ 0 ],
  459. contains(
  460. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  461. 'event_notification'
  462. )
  463. )
  464. # Send again the syntax keywords after restarting the server.
  465. ycm.RestartServer()
  466. WaitUntilReady()
  467. ycm.OnFileReadyToParse()
  468. assert_that(
  469. # Positional arguments passed to PostDataToHandlerAsync.
  470. post_data_to_handler_async.call_args[ 0 ],
  471. contains(
  472. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  473. 'event_notification'
  474. )
  475. )