Пример #1
0
class DiagnosticsTest( TestCase ):
  @SharedYcmd
  def test_Diagnostics_DoesntWork( self, app ):
    with PatchCompleter( DummyCompleter, filetype = 'dummy_filetype' ):
      diag_data = BuildRequest( contents = "foo = 5",
                                line_num = 2,
                                filetype = 'dummy_filetype' )

      response = app.post_json( '/detailed_diagnostic',
                                diag_data,
                                expect_errors = True )

      assert_that( response.status_code,
                   equal_to( requests.codes.internal_server_error ) )
      assert_that( response.json, ErrorMatcher( NoDiagnosticSupport ) )


  @SharedYcmd
  @patch( 'ycmd.tests.test_utils.DummyCompleter.GetDetailedDiagnostic',
          return_value = BuildDisplayMessageResponse( 'detailed diagnostic' ) )
  def test_Diagnostics_DoesWork( self, app, *args ):
    with PatchCompleter( DummyCompleter, filetype = 'dummy_filetype' ):
      diag_data = BuildRequest( contents = 'foo = 5',
                                filetype = 'dummy_filetype' )

      response = app.post_json( '/detailed_diagnostic', diag_data )
      assert_that( response.json, MessageMatcher( 'detailed diagnostic' ) )
Пример #2
0
from ycmd.tests import SharedYcmd
from ycmd.tests.test_utils import ( BuildRequest, DummyCompleter, ErrorMatcher,
                                    MessageMatcher, PatchCompleter )


@SharedYcmd
def Diagnostics_DoesntWork_test( app ):
  with PatchCompleter( DummyCompleter, filetype = 'dummy_filetype' ):
    diag_data = BuildRequest( contents = "foo = 5",
                              line_num = 2,
                              filetype = 'dummy_filetype' )

    response = app.post_json( '/detailed_diagnostic',
                              diag_data,
                              expect_errors = True )

    eq_( response.status_code, requests.codes.internal_server_error )
    assert_that( response.json, ErrorMatcher( NoDiagnosticSupport ) )


@SharedYcmd
@patch( 'ycmd.tests.test_utils.DummyCompleter.GetDetailedDiagnostic',
        return_value = BuildDisplayMessageResponse( 'detailed diagnostic' ) )
def Diagnostics_DoesWork_test( app, *args ):
  with PatchCompleter( DummyCompleter, filetype = 'dummy_filetype' ):
    diag_data = BuildRequest( contents = 'foo = 5',
                              filetype = 'dummy_filetype' )

    response = app.post_json( '/detailed_diagnostic', diag_data )
    assert_that( response.json, MessageMatcher( 'detailed diagnostic' ) )