Merge branch 'completion_tests' of https://github.com/rcorre/qutebrowser into rcorre-completion_tests

This commit is contained in:
Florian Bruhin 2016-09-15 16:47:32 +02:00
commit 9db3d3f7c3

View File

@ -42,21 +42,19 @@ def _check_completions(model, expected):
...
}
"""
actual = {}
assert model.rowCount() == len(expected)
for i in range(0, model.rowCount()):
category = model.item(i)
entries = []
for j in range(0, category.rowCount()):
name = category.child(j, 0)
desc = category.child(j, 1)
misc = category.child(j, 2)
entries.append((name.text(), desc.text(), misc.text()))
actual[category.text()] = entries
for cat_name, expected_entries in expected.items():
assert cat_name in actual
actual_items = actual[cat_name]
for expected_item in expected_entries:
assert expected_item in actual_items
actual_cat = model.item(i)
catname = actual_cat.text()
assert catname in expected
expected_cat = expected[catname]
assert actual_cat.rowCount() == len(expected_cat)
for j in range(0, actual_cat.rowCount()):
name = actual_cat.child(j, 0)
desc = actual_cat.child(j, 1)
misc = actual_cat.child(j, 2)
actual_item = (name.text(), desc.text(), misc.text())
assert actual_item in expected_cat
def _patch_cmdutils(monkeypatch, stubs, symbol):
@ -96,6 +94,10 @@ def _patch_configdata(monkeypatch, stubs, symbol):
value.SettingValue(stubs.FakeConfigType(('on', 'off')),
default='off'),
'Whether to respond to voice commands'))),
('searchengines', sections.ValueList(
stubs.FakeConfigType(), stubs.FakeConfigType(),
('DEFAULT', 'https://duckduckgo.com/?q={}'),
)),
])
monkeypatch.setattr(symbol, data)
@ -105,6 +107,7 @@ def _patch_config_section_desc(monkeypatch, stubs, symbol):
section_desc = {
'general': 'General/miscellaneous options.',
'ui': 'General options related to the user interface.',
'searchengines': 'Definitions of search engines ...',
}
monkeypatch.setattr(symbol, section_desc)
@ -225,6 +228,7 @@ def test_help_completion(qtmodeltester, monkeypatch, stubs, key_config_stub):
('ui->gesture', 'Waggle your hands to control qutebrowser', ''),
('ui->mind', 'Enable mind-control ui (experimental)', ''),
('ui->voice', 'Whether to respond to voice commands', ''),
('searchengines->DEFAULT', '', ''),
]
})
@ -401,6 +405,7 @@ def test_setting_section_completion(qtmodeltester, monkeypatch, stubs):
"Sections": [
('general', 'General/miscellaneous options.', ''),
('ui', 'General options related to the user interface.', ''),
('searchengines', 'Definitions of search engines ...', ''),
]
})
@ -425,6 +430,24 @@ def test_setting_option_completion(qtmodeltester, monkeypatch, stubs,
})
def test_setting_option_completion_valuelist(qtmodeltester, monkeypatch, stubs,
config_stub):
module = 'qutebrowser.completion.models.configmodel'
_patch_configdata(monkeypatch, stubs, module + '.configdata.DATA')
config_stub.data = {
'searchengines': {
'DEFAULT': 'https://duckduckgo.com/?q={}'
}
}
model = configmodel.SettingOptionCompletionModel('searchengines')
qtmodeltester.data_display_may_return_none = True
qtmodeltester.check(model)
_check_completions(model, {
'searchengines': [('DEFAULT', '', 'https://duckduckgo.com/?q={}')]
})
def test_setting_value_completion(qtmodeltester, monkeypatch, stubs,
config_stub):
module = 'qutebrowser.completion.models.configmodel'
@ -471,6 +494,7 @@ def test_bind_completion(qtmodeltester, monkeypatch, stubs, config_stub,
('stop', 'stop qutebrowser', 's'),
('drop', 'drop all user data', ''),
('hide', '', ''),
('roll', 'never gonna give you up', 'rr'),
('rock', "Alias for 'roll'", 'ro'),
]
})