Skip to content

Commit

Permalink
Ensuring /event_notification always returns JSON
Browse files Browse the repository at this point in the history
Empty string is not valid JSON.

Fixes ycm-core#51.
  • Loading branch information
Valloric committed Nov 18, 2014
1 parent 36167a0 commit 67c2e3c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions ycmd/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def EventNotification():

if response_data:
return _JsonResponse( response_data )
return _JsonResponse( {} )


@app.post( '/run_completer_command' )
Expand Down
4 changes: 2 additions & 2 deletions ycmd/tests/diagnostics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def Diagnostics_ClangCompleter_PragmaOnceWarningIgnored_test():
filepath = '/foo.h',
filetype = 'cpp' )

response = app.post_json( '/event_notification', event_data )
assert_that( response.body, empty() )
response = app.post_json( '/event_notification', event_data ).json
assert_that( response, empty() )


@with_setup( Setup )
Expand Down
9 changes: 9 additions & 0 deletions ycmd/tests/misc_handlers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ def UserOptions_Works_test():
app.post_json( '/user_options', options )
eq_( options, app.get( '/user_options' ).json )



@with_setup( Setup )
def EventNotification_AlwaysJsonResponse_test():
app = TestApp( handlers.app )
event_data = BuildRequest( contents = 'foo foogoo ba',
event_name = 'FileReadyToParse' )

app.post_json( '/event_notification', event_data ).json

0 comments on commit 67c2e3c

Please sign in to comment.