bdd: Add some tests for :set.
This commit is contained in:
parent
128465f12b
commit
a26e99f004
60
tests/integration/features/set.feature
Normal file
60
tests/integration/features/set.feature
Normal file
@ -0,0 +1,60 @@
|
||||
Feature: Setting settings.
|
||||
|
||||
Background:
|
||||
Given I set ui -> message-timeout to 100
|
||||
|
||||
Scenario: Using :set
|
||||
When I run :set colors statusbar.bg magenta
|
||||
Then colors -> statusbar.bg should be magenta
|
||||
|
||||
Scenario: Only a section
|
||||
When I run :set colors
|
||||
Then the error "set: Either both section and option have to be given, or neither!" should be shown.
|
||||
|
||||
Scenario: Without value
|
||||
When I run :set colors statusbar.bg
|
||||
Then the error "set: The following arguments are required: value" should be shown.
|
||||
|
||||
Scenario: Invalid section
|
||||
When I run :set blah blub foo
|
||||
Then the error "set: NoSectionError - Section 'blah' does not exist!" should be shown.
|
||||
|
||||
Scenario: Invalid option
|
||||
When I run :set general blub foo
|
||||
Then the error "set: NoOptionError - No option 'blub' in section 'general'" should be shown.
|
||||
|
||||
Scenario: Toggling an option
|
||||
When I run :set general auto-save-config false
|
||||
And I run :set general auto-save-config!
|
||||
Then general -> auto-save-config should be True
|
||||
|
||||
Scenario: Toggling a non-bool option
|
||||
When I run :set colors statusbar.bg!
|
||||
Then the error "set: Attempted inversion of non-boolean value." should be shown.
|
||||
|
||||
Scenario: Getting an option
|
||||
When I run :set colors statusbar.bg magenta
|
||||
And I run :set colors statusbar.bg?
|
||||
Then the message "colors statusbar.bg = magenta" should be shown.
|
||||
|
||||
Scenario: Using -p
|
||||
When I run :set -p colors statusbar.bg red
|
||||
Then the message "colors statusbar.bg = red" should be shown.
|
||||
|
||||
Scenario: Setting a temporary option
|
||||
# We don't actually check if the option is temporary as this isn't easy
|
||||
# to check.
|
||||
When I run :set -t colors statusbar.bg green
|
||||
Then colors -> statusbar.bg should be green
|
||||
|
||||
Scenario: Opening qute:settings
|
||||
When I run :set
|
||||
And I wait for "load status for <qutebrowser.browser.webview.WebView tab_id=0 url='qute:settings'>: LoadStatus.success" in the log
|
||||
Then the session should look like:
|
||||
windows:
|
||||
- tabs:
|
||||
- active: true
|
||||
history:
|
||||
- url: about:blank
|
||||
- active: true
|
||||
url: qute:settings
|
32
tests/integration/features/test_set.py
Normal file
32
tests/integration/features/test_set.py
Normal file
@ -0,0 +1,32 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
|
||||
import pytest_bdd as bdd
|
||||
bdd.scenarios('set.feature')
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse("{section} -> {option} should be {value}"))
|
||||
def check_option(quteproc, section, option, value):
|
||||
quteproc.send_cmd(':set {} {}?'.format(section, option))
|
||||
msg = quteproc.wait_for(loglevel=logging.INFO, category='message',
|
||||
message='{} {} = *'.format(section, option))
|
||||
actual_value = msg.message.split(' = ')[1]
|
||||
assert actual_value == value
|
Loading…
Reference in New Issue
Block a user