event_notification_test.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. # coding: utf-8
  2. #
  3. # Copyright (C) 2015-2018 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 response (as called by EventNotification.Response) which
  71. # calls the supplied callback method. Generally this callback just raises an
  72. # apropriate exception, otherwise it would have to return a mock future
  73. # 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. See
  77. # https://docs.python.org/dev/library/unittest.mock.html#where-to-patch for
  78. # 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. ycm.HandleFileParseRequest()
  241. vim_command.assert_not_called()
  242. eq_( ycm.GetErrorCount(), 1 )
  243. eq_( ycm.GetWarningCount(), 0 )
  244. @patch( 'vim.command' )
  245. def _Check_FileReadyToParse_Diagnostic_Warning( ycm, vim_command ):
  246. # Tests Vim sign placement/unplacement and error/warning count python API
  247. # when one warning is returned.
  248. # Should be called after _Check_FileReadyToParse_Diagnostic_Error
  249. def DiagnosticResponse( *args ):
  250. start = Location( 2, 2, 'TEST_BUFFER' )
  251. end = Location( 2, 4, 'TEST_BUFFER' )
  252. extent = Range( start, end )
  253. diagnostic = Diagnostic( [], start, extent, 'cast', 'WARNING' )
  254. return [ BuildDiagnosticData( diagnostic ) ]
  255. with MockArbitraryBuffer( 'cpp' ):
  256. with MockEventNotification( DiagnosticResponse ):
  257. ycm.OnFileReadyToParse()
  258. ok_( ycm.FileParseRequestReady() )
  259. ycm.HandleFileParseRequest()
  260. vim_command.assert_has_calls( [
  261. PlaceSign_Call( 2, 2, 1, False ),
  262. UnplaceSign_Call( 1, 1 )
  263. ] )
  264. eq_( ycm.GetErrorCount(), 0 )
  265. eq_( ycm.GetWarningCount(), 1 )
  266. # Consequent calls to HandleFileParseRequest shouldn't mess with
  267. # existing diagnostics, when there is no new parse request.
  268. vim_command.reset_mock()
  269. ycm.HandleFileParseRequest()
  270. vim_command.assert_not_called()
  271. eq_( ycm.GetErrorCount(), 0 )
  272. eq_( ycm.GetWarningCount(), 1 )
  273. @patch( 'vim.command' )
  274. def _Check_FileReadyToParse_Diagnostic_Clean( ycm, vim_command ):
  275. # Tests Vim sign unplacement and error/warning count python API
  276. # when there are no errors/warnings left.
  277. # Should be called after _Check_FileReadyToParse_Diagnostic_Warning
  278. with MockArbitraryBuffer( 'cpp' ):
  279. with MockEventNotification( MagicMock( return_value = [] ) ):
  280. ycm.OnFileReadyToParse()
  281. ycm.HandleFileParseRequest()
  282. vim_command.assert_has_calls( [
  283. UnplaceSign_Call( 2, 1 )
  284. ] )
  285. eq_( ycm.GetErrorCount(), 0 )
  286. eq_( ycm.GetWarningCount(), 0 )
  287. @patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
  288. @YouCompleteMeInstance( { 'collect_identifiers_from_tags_files': 1 } )
  289. def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
  290. ycm, *args ):
  291. unicode_dir = PathToTestFile( 'uni¢𐍈d€' )
  292. current_buffer_file = PathToTestFile( 'uni¢𐍈d€', 'current_buffer' )
  293. current_buffer = VimBuffer( name = current_buffer_file,
  294. contents = [ 'current_buffer_contents' ],
  295. filetype = 'some_filetype' )
  296. with patch( 'ycm.client.event_notification.EventNotification.'
  297. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  298. with CurrentWorkingDirectory( unicode_dir ):
  299. with MockVimBuffers( [ current_buffer ], current_buffer, ( 1, 5 ) ):
  300. ycm.OnFileReadyToParse()
  301. assert_that(
  302. # Positional arguments passed to PostDataToHandlerAsync.
  303. post_data_to_handler_async.call_args[ 0 ],
  304. contains(
  305. has_entries( {
  306. 'filepath': current_buffer_file,
  307. 'line_num': 1,
  308. 'column_num': 6,
  309. 'file_data': has_entries( {
  310. current_buffer_file: has_entries( {
  311. 'contents': 'current_buffer_contents\n',
  312. 'filetypes': [ 'some_filetype' ]
  313. } )
  314. } ),
  315. 'event_name': 'FileReadyToParse',
  316. 'tag_files': has_item( PathToTestFile( 'uni¢𐍈d€', 'tags' ) )
  317. } ),
  318. 'event_notification'
  319. )
  320. )
  321. @patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
  322. @YouCompleteMeInstance()
  323. def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test(
  324. ycm, *args ):
  325. current_buffer_file = os.path.realpath( 'current_buffer' )
  326. current_buffer = VimBuffer( name = current_buffer_file,
  327. number = 1,
  328. contents = [ 'current_buffer_contents' ],
  329. filetype = 'some_filetype',
  330. modified = False )
  331. modified_buffer_file = os.path.realpath( 'modified_buffer' )
  332. modified_buffer = VimBuffer( name = modified_buffer_file,
  333. number = 2,
  334. contents = [ 'modified_buffer_contents' ],
  335. filetype = 'some_filetype',
  336. modified = True )
  337. unmodified_buffer_file = os.path.realpath( 'unmodified_buffer' )
  338. unmodified_buffer = VimBuffer( name = unmodified_buffer_file,
  339. number = 3,
  340. contents = [ 'unmodified_buffer_contents' ],
  341. filetype = 'some_filetype',
  342. modified = False )
  343. with patch( 'ycm.client.event_notification.EventNotification.'
  344. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  345. with MockVimBuffers( [ current_buffer, modified_buffer, unmodified_buffer ],
  346. current_buffer,
  347. ( 1, 5 ) ):
  348. ycm.OnBufferVisit()
  349. assert_that(
  350. # Positional arguments passed to PostDataToHandlerAsync.
  351. post_data_to_handler_async.call_args[ 0 ],
  352. contains(
  353. has_entries( {
  354. 'filepath': current_buffer_file,
  355. 'line_num': 1,
  356. 'column_num': 6,
  357. 'file_data': has_entries( {
  358. current_buffer_file: has_entries( {
  359. 'contents': 'current_buffer_contents\n',
  360. 'filetypes': [ 'some_filetype' ]
  361. } ),
  362. modified_buffer_file: has_entries( {
  363. 'contents': 'modified_buffer_contents\n',
  364. 'filetypes': [ 'some_filetype' ]
  365. } )
  366. } ),
  367. 'event_name': 'BufferVisit'
  368. } ),
  369. 'event_notification'
  370. )
  371. )
  372. @YouCompleteMeInstance()
  373. def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test(
  374. ycm ):
  375. current_buffer_file = os.path.realpath( 'current_βuffer' )
  376. current_buffer = VimBuffer( name = current_buffer_file,
  377. number = 1,
  378. contents = [ 'current_buffer_contents' ],
  379. filetype = 'some_filetype',
  380. modified = True )
  381. deleted_buffer_file = os.path.realpath( 'deleted_βuffer' )
  382. deleted_buffer = VimBuffer( name = deleted_buffer_file,
  383. number = 2,
  384. contents = [ 'deleted_buffer_contents' ],
  385. filetype = 'some_filetype',
  386. modified = False )
  387. with patch( 'ycm.client.event_notification.EventNotification.'
  388. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  389. with MockVimBuffers( [ current_buffer, deleted_buffer ], current_buffer ):
  390. ycm.OnBufferUnload( deleted_buffer.number )
  391. assert_that(
  392. # Positional arguments passed to PostDataToHandlerAsync.
  393. post_data_to_handler_async.call_args[ 0 ],
  394. contains(
  395. has_entries( {
  396. 'filepath': deleted_buffer_file,
  397. 'line_num': 1,
  398. 'column_num': 1,
  399. 'file_data': has_entries( {
  400. current_buffer_file: has_entries( {
  401. 'contents': 'current_buffer_contents\n',
  402. 'filetypes': [ 'some_filetype' ]
  403. } ),
  404. deleted_buffer_file: has_entries( {
  405. 'contents': 'deleted_buffer_contents\n',
  406. 'filetypes': [ 'some_filetype' ]
  407. } )
  408. } ),
  409. 'event_name': 'BufferUnload'
  410. } ),
  411. 'event_notification'
  412. )
  413. )
  414. @patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
  415. return_value = [ 'foo', 'bar' ] )
  416. @YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
  417. def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
  418. ycm, *args ):
  419. current_buffer = VimBuffer( name = 'current_buffer',
  420. filetype = 'some_filetype' )
  421. with patch( 'ycm.client.event_notification.EventNotification.'
  422. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  423. with MockVimBuffers( [ current_buffer ], current_buffer ):
  424. ycm.OnFileReadyToParse()
  425. assert_that(
  426. # Positional arguments passed to PostDataToHandlerAsync.
  427. post_data_to_handler_async.call_args[ 0 ],
  428. contains(
  429. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  430. 'event_notification'
  431. )
  432. )
  433. # Do not send again syntax keywords in subsequent requests.
  434. ycm.OnFileReadyToParse()
  435. assert_that(
  436. # Positional arguments passed to PostDataToHandlerAsync.
  437. post_data_to_handler_async.call_args[ 0 ],
  438. contains(
  439. is_not( has_key( 'syntax_keywords' ) ),
  440. 'event_notification'
  441. )
  442. )
  443. @patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
  444. return_value = [ 'foo', 'bar' ] )
  445. @YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
  446. def EventNotification_FileReadyToParse_SyntaxKeywords_ClearCacheIfRestart_test(
  447. ycm, *args ):
  448. current_buffer = VimBuffer( name = 'current_buffer',
  449. filetype = 'some_filetype' )
  450. with patch( 'ycm.client.event_notification.EventNotification.'
  451. 'PostDataToHandlerAsync' ) as post_data_to_handler_async:
  452. with MockVimBuffers( [ current_buffer ], current_buffer ):
  453. ycm.OnFileReadyToParse()
  454. assert_that(
  455. # Positional arguments passed to PostDataToHandlerAsync.
  456. post_data_to_handler_async.call_args[ 0 ],
  457. contains(
  458. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  459. 'event_notification'
  460. )
  461. )
  462. # Send again the syntax keywords after restarting the server.
  463. ycm.RestartServer()
  464. WaitUntilReady()
  465. ycm.OnFileReadyToParse()
  466. assert_that(
  467. # Positional arguments passed to PostDataToHandlerAsync.
  468. post_data_to_handler_async.call_args[ 0 ],
  469. contains(
  470. has_entry( 'syntax_keywords', has_items( 'foo', 'bar' ) ),
  471. 'event_notification'
  472. )
  473. )