From be07107b1cd0d0eff91994d48c2932be811e584c Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Wed, 15 Feb 2017 21:29:00 -0500 Subject: [PATCH] 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. --- qutebrowser/completion/completer.py | 9 ++--- tests/end2end/features/completion.feature | 40 ++++--------------- tests/end2end/features/test_completion_bdd.py | 2 +- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 8742156a3..f403354c3 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -97,6 +97,7 @@ class Completer(QObject): if not before_cursor: # '|' or 'set|' model = miscmodels.command() + log.completion.debug('Starting command completion') return sortfilter.CompletionFilterModel(source=model, parent=self) try: cmd = cmdutils.cmd_dict[before_cursor[0]] @@ -113,6 +114,8 @@ class Completer(QObject): if completion is None: return None model = self._get_completion_model(completion, before_cursor[1:]) + log.completion.debug('Starting {} completion' + .format(completion.__name__)) return model def _quote(self, s): @@ -237,11 +240,7 @@ class Completer(QObject): pattern = pattern.strip("'\"") model = self._get_new_completion(before_cursor, pattern) - - log.completion.debug("Setting completion model to {} with pattern '{}'" - .format(model.srcmodel.__class__.__name__ if model else 'None', - pattern)) - + log.completion.debug("Setting pattern to '{}'".format(pattern)) completion.set_model(model, pattern) def _change_completed_part(self, newtext, before, after, immediate=False): diff --git a/tests/end2end/features/completion.feature b/tests/end2end/features/completion.feature index b6c62336c..e93518199 100644 --- a/tests/end2end/features/completion.feature +++ b/tests/end2end/features/completion.feature @@ -32,23 +32,23 @@ Feature: Using completion Scenario: Using command completion When I run :set-cmd-text : - Then the completion model should be CommandCompletionModel + Then the completion model should be command Scenario: Using help completion 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 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 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 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 Given I open data/hello.txt @@ -62,37 +62,11 @@ Feature: Using completion Scenario: Using option completion 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 When I run :set-cmd-text -s :set colors statusbar.bg - Then the completion model should be SettingValueCompletionModel - - 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 + Then the completion model should be value Scenario: Deleting an open tab via the completion Given I have a fresh instance diff --git a/tests/end2end/features/test_completion_bdd.py b/tests/end2end/features/test_completion_bdd.py index f4ada848f..4a06bfbc0 100644 --- a/tests/end2end/features/test_completion_bdd.py +++ b/tests/end2end/features/test_completion_bdd.py @@ -24,5 +24,5 @@ bdd.scenarios('completion.feature') @bdd.then(bdd.parsers.parse("the completion model should be {model}")) def check_model(quteproc, model): """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)