def test_multi_path_completion(self):
        line = 'ls a/b/c'
        cmds = mock_commands()
        conts = ['container']
        leaves = ['leaf']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, 'co', 0), 'container/')
        self.assertEqual(completer.complete(line, 'co', 1), None)
    def test_leaf_with_spaces_completion(self):
        line = 'ls '
        cmds = mock_commands()
        conts = ['container']
        leaves = ['le af']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, 'le', 0), 'le\\ af')
        self.assertEqual(completer.complete(line, 'le', 1), None)
    def test_multi_path_completion(self):
        line = 'ls a/b/c'
        cmds = mock_commands()
        conts = ['container']
        leaves = ['leaf']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, 'co', 0), 'container/')
        self.assertEqual(completer.complete(line, 'co', 1), None)
    def test_leaf_with_spaces_completion(self):
        line = 'ls '
        cmds = mock_commands()
        conts = ['container']
        leaves = ['le af']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, 'le', 0), 'le\\ af')
        self.assertEqual(completer.complete(line, 'le', 1), None)
    def test_option_completion(self):
        line = 'ls '
        cmds = mock_commands()
        conts = ['container']
        leaves = ['leaf']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, '-', 0), '--long')
        self.assertEqual(completer.complete(line, '-', 1), '-l')
        self.assertEqual(completer.complete(line, '-', 2), None)
    def test_option_completion(self):
        line = 'ls '
        cmds = mock_commands()
        conts = ['container']
        leaves = ['leaf']

        current = ItemMock(conts, leaves)
        completer = Completer(cmds, current)
        completer._next_item = MockNextItem(conts, leaves)
        self.assertEqual(completer.complete(line, '-', 0), '--long')
        self.assertEqual(completer.complete(line, '-', 1), '-l')
        self.assertEqual(completer.complete(line, '-', 2), None)