Merge branch 'rcorre-completion_tests'
This commit is contained in:
commit
0b9c3dedef
@ -42,21 +42,19 @@ def _check_completions(model, expected):
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
actual = {}
|
assert model.rowCount() == len(expected)
|
||||||
for i in range(0, model.rowCount()):
|
for i in range(0, model.rowCount()):
|
||||||
category = model.item(i)
|
actual_cat = model.item(i)
|
||||||
entries = []
|
catname = actual_cat.text()
|
||||||
for j in range(0, category.rowCount()):
|
assert catname in expected
|
||||||
name = category.child(j, 0)
|
expected_cat = expected[catname]
|
||||||
desc = category.child(j, 1)
|
assert actual_cat.rowCount() == len(expected_cat)
|
||||||
misc = category.child(j, 2)
|
for j in range(0, actual_cat.rowCount()):
|
||||||
entries.append((name.text(), desc.text(), misc.text()))
|
name = actual_cat.child(j, 0)
|
||||||
actual[category.text()] = entries
|
desc = actual_cat.child(j, 1)
|
||||||
for cat_name, expected_entries in expected.items():
|
misc = actual_cat.child(j, 2)
|
||||||
assert cat_name in actual
|
actual_item = (name.text(), desc.text(), misc.text())
|
||||||
actual_items = actual[cat_name]
|
assert actual_item in expected_cat
|
||||||
for expected_item in expected_entries:
|
|
||||||
assert expected_item in actual_items
|
|
||||||
|
|
||||||
|
|
||||||
def _patch_cmdutils(monkeypatch, stubs, symbol):
|
def _patch_cmdutils(monkeypatch, stubs, symbol):
|
||||||
@ -96,6 +94,10 @@ def _patch_configdata(monkeypatch, stubs, symbol):
|
|||||||
value.SettingValue(stubs.FakeConfigType(('on', 'off')),
|
value.SettingValue(stubs.FakeConfigType(('on', 'off')),
|
||||||
default='off'),
|
default='off'),
|
||||||
'Whether to respond to voice commands'))),
|
'Whether to respond to voice commands'))),
|
||||||
|
('searchengines', sections.ValueList(
|
||||||
|
stubs.FakeConfigType(), stubs.FakeConfigType(),
|
||||||
|
('DEFAULT', 'https://duckduckgo.com/?q={}'),
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
monkeypatch.setattr(symbol, data)
|
monkeypatch.setattr(symbol, data)
|
||||||
|
|
||||||
@ -105,6 +107,7 @@ def _patch_config_section_desc(monkeypatch, stubs, symbol):
|
|||||||
section_desc = {
|
section_desc = {
|
||||||
'general': 'General/miscellaneous options.',
|
'general': 'General/miscellaneous options.',
|
||||||
'ui': 'General options related to the user interface.',
|
'ui': 'General options related to the user interface.',
|
||||||
|
'searchengines': 'Definitions of search engines ...',
|
||||||
}
|
}
|
||||||
monkeypatch.setattr(symbol, section_desc)
|
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->gesture', 'Waggle your hands to control qutebrowser', ''),
|
||||||
('ui->mind', 'Enable mind-control ui (experimental)', ''),
|
('ui->mind', 'Enable mind-control ui (experimental)', ''),
|
||||||
('ui->voice', 'Whether to respond to voice commands', ''),
|
('ui->voice', 'Whether to respond to voice commands', ''),
|
||||||
|
('searchengines->DEFAULT', '', ''),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -401,6 +405,7 @@ def test_setting_section_completion(qtmodeltester, monkeypatch, stubs):
|
|||||||
"Sections": [
|
"Sections": [
|
||||||
('general', 'General/miscellaneous options.', ''),
|
('general', 'General/miscellaneous options.', ''),
|
||||||
('ui', 'General options related to the user interface.', ''),
|
('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,
|
def test_setting_value_completion(qtmodeltester, monkeypatch, stubs,
|
||||||
config_stub):
|
config_stub):
|
||||||
module = 'qutebrowser.completion.models.configmodel'
|
module = 'qutebrowser.completion.models.configmodel'
|
||||||
@ -471,6 +494,7 @@ def test_bind_completion(qtmodeltester, monkeypatch, stubs, config_stub,
|
|||||||
('stop', 'stop qutebrowser', 's'),
|
('stop', 'stop qutebrowser', 's'),
|
||||||
('drop', 'drop all user data', ''),
|
('drop', 'drop all user data', ''),
|
||||||
('hide', '', ''),
|
('hide', '', ''),
|
||||||
|
('roll', 'never gonna give you up', 'rr'),
|
||||||
('rock', "Alias for 'roll'", 'ro'),
|
('rock', "Alias for 'roll'", 'ro'),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user