diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 78f134051..fa7f60fa5 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -349,39 +349,11 @@ class FakeTimer(QObject): return self._started -class FakeConfigSection: - - """A stub for a KeyValue entry in configdata.DATA.""" - - def __init__(self, *entries): - self.values = collections.OrderedDict() - self.descriptions = {} - for name, value, desc in entries: - self.values[name] = value - self.descriptions[name] = desc - - def __iter__(self): - """Iterate over all set values.""" - return iter(self.values) - - def __getitem__(self, key): - return self.values[key] - - -class FakeSettingValue: - - """A stub for a SettingValue entry in configdata.DATA[section].""" - - def __init__(self, valid_values, default=None): - self.typ = FakeConfigType(valid_values) - self.default = lambda: default - - class FakeConfigType: - """A stub for the typ attribute of a FakeSettingValue.""" + """A stub to provide valid_values for typ attribute of a SettingValue.""" - def __init__(self, valid_values): + def __init__(self, *valid_values): # normally valid_values would be a ValidValues, but for simplicity of # testing this can be a simple list: [(val, desc), (val, desc), ...] self.complete = lambda: [(val, '') for val in valid_values] diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index 6cb736a04..8c19d4bee 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -28,6 +28,7 @@ from PyQt5.QtWidgets import QTreeView from qutebrowser.completion.models import miscmodels, urlmodel, configmodel from qutebrowser.browser.webkit import history +from qutebrowser.config import sections, value def _get_completions(model): @@ -68,22 +69,27 @@ def _patch_cmdutils(monkeypatch, stubs, symbol): def _patch_configdata(monkeypatch, stubs, symbol): """Patch the configdata module to provide fake data.""" data = collections.OrderedDict([ - ('general', stubs.FakeConfigSection( + ('general', sections.KeyValue( ('time', - stubs.FakeSettingValue(('fast', 'slow'), 'slow'), + value.SettingValue(stubs.FakeConfigType('fast', 'slow'), + default='slow'), 'Is an illusion.\n\nLunchtime doubly so.'), ('volume', - stubs.FakeSettingValue(('0', '11'), '11'), + value.SettingValue(stubs.FakeConfigType('0', '11'), + default='11'), 'Goes to 11'))), - ('ui', stubs.FakeConfigSection( + ('ui', sections.KeyValue( ('gesture', - stubs.FakeSettingValue(('on', 'off'), 'off'), + value.SettingValue(stubs.FakeConfigType(('on', 'off')), + default='off'), 'Waggle your hands to control qutebrowser'), ('mind', - stubs.FakeSettingValue(('on', 'off'), 'off'), + value.SettingValue(stubs.FakeConfigType(('on', 'off')), + default='off'), 'Enable mind-control ui (experimental)'), ('voice', - stubs.FakeSettingValue(('on', 'off'), 'off'), + value.SettingValue(stubs.FakeConfigType(('on', 'off')), + default='off'), 'Whether to respond to voice commands'))), ]) monkeypatch.setattr(symbol, data)