def HandlePollResponse_NoMessages_test():
  assert_that( _HandlePollResponse( True, None ), equal_to( True ) )

  # Other non-False responses mean the same thing
  assert_that( _HandlePollResponse( '', None ), equal_to( True ) )
  assert_that( _HandlePollResponse( 1, None ), equal_to( True ) )
  assert_that( _HandlePollResponse( {}, None ), equal_to( True ) )
Example #2
0
def HandlePollResponse_NoMessages_test():
    assert_that(_HandlePollResponse(True, None), equal_to(True))

    # Other non-False responses mean the same thing
    assert_that(_HandlePollResponse('', None), equal_to(True))
    assert_that(_HandlePollResponse(1, None), equal_to(True))
    assert_that(_HandlePollResponse({}, None), equal_to(True))
Example #3
0
def HandlePollResponse_MultipleDiagnostics_test():
    diagnostics_handler = ExtendedMock()
    messages = [
        {
            'filepath': 'foo',
            'diagnostics': ['PLACEHOLDER1']
        },
        {
            'filepath': 'bar',
            'diagnostics': ['PLACEHOLDER2']
        },
        {
            'filepath': 'baz',
            'diagnostics': ['PLACEHOLDER3']
        },
        {
            'filepath': 'foo',
            'diagnostics': ['PLACEHOLDER4']
        },
    ]
    assert_that(_HandlePollResponse(messages, diagnostics_handler),
                equal_to(True))
    diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls(
        [
            call('foo', ['PLACEHOLDER1']),
            call('bar', ['PLACEHOLDER2']),
            call('baz', ['PLACEHOLDER3']),
            call('foo', ['PLACEHOLDER4'])
        ])
Example #4
0
def HandlePollResponse_SingleMessage_test(post_vim_message):
    assert_that(_HandlePollResponse([{
        'message': 'this is a message'
    }], None), equal_to(True))

    post_vim_message.assert_has_exact_calls(
        [call('this is a message', warning=False, truncate=True)])
def HandlePollResponse_MultipleMessagesAndDiagnostics_test( post_vim_message ):
  diagnostics_handler = ExtendedMock()
  messages = [
    { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER1' ] },
    { 'message': 'On the first day of Christmas, my VimScript gave to me' },
    { 'filepath': 'bar', 'diagnostics': [ 'PLACEHOLDER2' ] },
    { 'message': 'A test file in a Command-T' },
    { 'filepath': 'baz', 'diagnostics': [ 'PLACEHOLDER3' ] },
    { 'message': 'On the second day of Christmas, my VimScript gave to me' },
    { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER4' ] },
    { 'message': 'Two popup menus, and a test file in a Command-T' },
  ]
  assert_that( _HandlePollResponse( messages, diagnostics_handler ),
               equal_to( True ) )
  diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls( [
    call( 'foo', [ 'PLACEHOLDER1' ] ),
    call( 'bar', [ 'PLACEHOLDER2' ] ),
    call( 'baz', [ 'PLACEHOLDER3' ] ),
    call( 'foo', [ 'PLACEHOLDER4' ] )
  ] )

  post_vim_message.assert_has_exact_calls( [
    call( 'On the first day of Christmas, my VimScript gave to me',
          warning=False,
          truncate=True ),
    call( 'A test file in a Command-T', warning=False, truncate=True ),
    call( 'On the second day of Christmas, my VimScript gave to me',
          warning=False,
          truncate=True ),
    call( 'Two popup menus, and a test file in a Command-T',
          warning=False,
          truncate=True ),
  ] )
Example #6
0
def HandlePollResponse_MultipleMessagesAndDiagnostics_test( post_vim_message ):
  diagnostics_handler = ExtendedMock()
  messages = [
    { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER1' ] },
    { 'message': 'On the first day of Christmas, my VimScript gave to me' },
    { 'filepath': 'bar', 'diagnostics': [ 'PLACEHOLDER2' ] },
    { 'message': 'A test file in a Command-T' },
    { 'filepath': 'baz', 'diagnostics': [ 'PLACEHOLDER3' ] },
    { 'message': 'On the second day of Christmas, my VimScript gave to me' },
    { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER4' ] },
    { 'message': 'Two popup menus, and a test file in a Command-T' },
  ]
  assert_that( _HandlePollResponse( messages, diagnostics_handler ),
               equal_to( True ) )
  diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls( [
    call( 'foo', [ 'PLACEHOLDER1' ] ),
    call( 'bar', [ 'PLACEHOLDER2' ] ),
    call( 'baz', [ 'PLACEHOLDER3' ] ),
    call( 'foo', [ 'PLACEHOLDER4' ] )
  ] )

  post_vim_message.assert_has_exact_calls( [
    call( 'On the first day of Christmas, my VimScript gave to me',
          warning=False,
          truncate=True ),
    call( 'A test file in a Command-T', warning=False, truncate=True ),
    call( 'On the second day of Christmas, my VimScript gave to me',
          warning=False,
          truncate=True ),
    call( 'Two popup menus, and a test file in a Command-T',
          warning=False,
          truncate=True ),
  ] )
def HandlePollResponse_SingleMessage_test( post_vim_message ):
  assert_that( _HandlePollResponse( [ { 'message': 'this is a message' } ] ,
                                    None ),
               equal_to( True ) )

  post_vim_message.assert_has_exact_calls( [
    call( 'this is a message', warning=False, truncate=True )
  ] )
def HandlePollResponse_SingleDiagnostic_test():
  diagnostics_handler = ExtendedMock()
  messages = [
    { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER' ] },
  ]
  assert_that( _HandlePollResponse( messages, diagnostics_handler ),
               equal_to( True ) )
  diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls( [
    call( 'foo', [ 'PLACEHOLDER' ] )
  ] )
  def test_HandlePollResponse_MultipleMessages( self, post_vim_message ):
    assert_that( _HandlePollResponse( [ { 'message': 'this is a message' },
                                        { 'message': 'this is another one' } ] ,
                                      None ),
                 equal_to( True ) )

    post_vim_message.assert_has_exact_calls( [
      call( 'this is a message', warning=False, truncate=True ),
      call( 'this is another one', warning=False, truncate=True )
    ] )
 def test_HandlePollResponse_SingleDiagnostic( self ):
   diagnostics_handler = ExtendedMock()
   messages = [
     { 'filepath': 'foo', 'diagnostics': [ 'PLACEHOLDER' ] },
   ]
   assert_that( _HandlePollResponse( messages, diagnostics_handler ),
                equal_to( True ) )
   diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls(
     [
       call( 'foo', [ 'PLACEHOLDER' ] )
     ] )
Example #11
0
def HandlePollResponse_PollingNotSupported_test():
    assert_that(_HandlePollResponse(False, None), equal_to(False))

    # 0 is not False
    assert_that(_HandlePollResponse(0, None), equal_to(True))
def HandlePollResponse_PollingNotSupported_test():
  assert_that( _HandlePollResponse( False, None ), equal_to( False ) )

  # 0 is not False
  assert_that( _HandlePollResponse( 0, None ), equal_to( True ) )