Fix end2end completion tests for SQL backend.

Change the logging to report the completion function name and have the end2end
tests check for this.

Remove the tests for realtime completion, as it was decided this is not an
important feature and the code is much simpler without it.
This commit is contained in:
Ryan Roden-Corrent 2017-02-15 21:29:00 -05:00
parent 6a04c4b3e8
commit be07107b1c
3 changed files with 12 additions and 39 deletions

View File

@ -97,6 +97,7 @@ class Completer(QObject):
if not before_cursor: if not before_cursor:
# '|' or 'set|' # '|' or 'set|'
model = miscmodels.command() model = miscmodels.command()
log.completion.debug('Starting command completion')
return sortfilter.CompletionFilterModel(source=model, parent=self) return sortfilter.CompletionFilterModel(source=model, parent=self)
try: try:
cmd = cmdutils.cmd_dict[before_cursor[0]] cmd = cmdutils.cmd_dict[before_cursor[0]]
@ -113,6 +114,8 @@ class Completer(QObject):
if completion is None: if completion is None:
return None return None
model = self._get_completion_model(completion, before_cursor[1:]) model = self._get_completion_model(completion, before_cursor[1:])
log.completion.debug('Starting {} completion'
.format(completion.__name__))
return model return model
def _quote(self, s): def _quote(self, s):
@ -237,11 +240,7 @@ class Completer(QObject):
pattern = pattern.strip("'\"") pattern = pattern.strip("'\"")
model = self._get_new_completion(before_cursor, pattern) model = self._get_new_completion(before_cursor, pattern)
log.completion.debug("Setting pattern to '{}'".format(pattern))
log.completion.debug("Setting completion model to {} with pattern '{}'"
.format(model.srcmodel.__class__.__name__ if model else 'None',
pattern))
completion.set_model(model, pattern) completion.set_model(model, pattern)
def _change_completed_part(self, newtext, before, after, immediate=False): def _change_completed_part(self, newtext, before, after, immediate=False):

View File

@ -32,23 +32,23 @@ Feature: Using completion
Scenario: Using command completion Scenario: Using command completion
When I run :set-cmd-text : When I run :set-cmd-text :
Then the completion model should be CommandCompletionModel Then the completion model should be command
Scenario: Using help completion Scenario: Using help completion
When I run :set-cmd-text -s :help When I run :set-cmd-text -s :help
Then the completion model should be HelpCompletionModel Then the completion model should be helptopic
Scenario: Using quickmark completion Scenario: Using quickmark completion
When I run :set-cmd-text -s :quickmark-load When I run :set-cmd-text -s :quickmark-load
Then the completion model should be QuickmarkCompletionModel Then the completion model should be quickmark
Scenario: Using bookmark completion Scenario: Using bookmark completion
When I run :set-cmd-text -s :bookmark-load When I run :set-cmd-text -s :bookmark-load
Then the completion model should be BookmarkCompletionModel Then the completion model should be bookmark
Scenario: Using bind completion Scenario: Using bind completion
When I run :set-cmd-text -s :bind X When I run :set-cmd-text -s :bind X
Then the completion model should be BindCompletionModel Then the completion model should be bind
Scenario: Using session completion Scenario: Using session completion
Given I open data/hello.txt Given I open data/hello.txt
@ -62,37 +62,11 @@ Feature: Using completion
Scenario: Using option completion Scenario: Using option completion
When I run :set-cmd-text -s :set colors When I run :set-cmd-text -s :set colors
Then the completion model should be SettingOptionCompletionModel Then the completion model should be option
Scenario: Using value completion Scenario: Using value completion
When I run :set-cmd-text -s :set colors statusbar.bg When I run :set-cmd-text -s :set colors statusbar.bg
Then the completion model should be SettingValueCompletionModel Then the completion model should be value
Scenario: Updating the completion in realtime
Given I have a fresh instance
And I set completion -> quick-complete to false
When I open data/hello.txt
And I run :set-cmd-text -s :buffer
And I run :completion-item-focus next
And I open data/hello2.txt in a new background tab
And I run :completion-item-focus next
And I open data/hello3.txt in a new background tab
And I run :completion-item-focus next
And I run :command-accept
Then the following tabs should be open:
- data/hello.txt
- data/hello2.txt
- data/hello3.txt (active)
Scenario: Updating the value completion in realtime
Given I set colors -> statusbar.bg to green
When I run :set-cmd-text -s :set colors statusbar.bg
And I set colors -> statusbar.bg to yellow
And I run :completion-item-focus next
And I run :completion-item-focus next
And I set colors -> statusbar.bg to red
And I run :command-accept
Then colors -> statusbar.bg should be yellow
Scenario: Deleting an open tab via the completion Scenario: Deleting an open tab via the completion
Given I have a fresh instance Given I have a fresh instance

View File

@ -24,5 +24,5 @@ bdd.scenarios('completion.feature')
@bdd.then(bdd.parsers.parse("the completion model should be {model}")) @bdd.then(bdd.parsers.parse("the completion model should be {model}"))
def check_model(quteproc, model): def check_model(quteproc, model):
"""Make sure the completion model was set to something.""" """Make sure the completion model was set to something."""
pattern = "Setting completion model to {} with pattern *".format(model) pattern = "Starting {} completion".format(model)
quteproc.wait_for(message=pattern) quteproc.wait_for(message=pattern)