def test_current_buffer_is_the_first(self): WANTED_BUFFER_NUMBER = 5 vim_mock = mock.Mock() vim_mock.current.buffer.number = WANTED_BUFFER_NUMBER vim_mock.buffers = [] vim_mock.buffers.append(mock.Mock(number=WANTED_BUFFER_NUMBER)) vim_mock.buffers.append(mock.Mock(number=27)) with mock.patch(__name__ + '.localcomplete.vim', vim_mock): self.assertEqual( localcomplete.get_current_buffer_index(), 0)
def test_getting_the_buffer_index_embedded_between_other_buffers(self): WANTED_BUFFER_NUMBER = 5 vim_mock = mock.Mock() vim_mock.current.buffer.number = WANTED_BUFFER_NUMBER vim_mock.buffers = [] vim_mock.buffers.append(mock.Mock(number=17)) vim_mock.buffers.append(mock.Mock(number=7)) vim_mock.buffers.append(mock.Mock(number=WANTED_BUFFER_NUMBER)) vim_mock.buffers.append(mock.Mock(number=27)) with mock.patch(__name__ + '.localcomplete.vim', vim_mock): self.assertEqual( localcomplete.get_current_buffer_index(), 2)