def test_valid_values(self): opt1 = configdata.Option( name='opt1', typ=configtypes.BoolAsk(), default='ask', backends=[usertypes.Backend.QtWebEngine], raw_backends=None, description='Hello World') opt2 = configdata.Option( name='opt2', typ=configtypes.ColorSystem(), default='rgb', backends=[usertypes.Backend.QtWebEngine], raw_backends=None, description='All colors are beautiful!') options = [(opt1, 'ask'), (opt2, 'rgb')] writer = configfiles.ConfigPyWriter(options, bindings={}, commented=False) text = '\n'.join(writer._gen_lines()) expected = textwrap.dedent(""" # Hello World # Type: BoolAsk # Valid values: # - true # - false # - ask c.opt1 = 'ask' # All colors are beautiful! # Type: ColorSystem # Valid values: # - rgb: Interpolate in the RGB color system. # - hsv: Interpolate in the HSV color system. # - hsl: Interpolate in the HSL color system. # - none: Don't show a gradient. c.opt2 = 'rgb' """) assert expected in text
def test_pattern(self): opt = configdata.Option( name='opt', typ=configtypes.BoolAsk(), default='ask', backends=[usertypes.Backend.QtWebEngine], raw_backends=None, description='Hello World') options = [ (urlmatch.UrlPattern('https://www.example.com/'), opt, 'ask'), ] writer = configfiles.ConfigPyWriter(options=options, bindings={}, commented=False) text = '\n'.join(writer._gen_lines()) expected = "config.set('opt', 'ask', 'https://www.example.com/')" assert expected in text
('network', sect.KeyValue( ('do-not-track', SettingValue( typ.Bool(), 'true'), "Value to send in the `DNT` header."), ('accept-language', SettingValue( typ.String(none_ok=True), 'en-US,en'), "Value to send in the `accept-language` header."), ('user-agent', SettingValue(typ.String(none_ok=True), ''), "User agent to send. Empty to send the default."), ('proxy', SettingValue(typ.Proxy(), 'system'), "The proxy to use.\n\n" "In addition to the listed values, you can use a `socks://...` or " "`http://...` URL."), ('proxy-dns-requests', SettingValue(typ.Bool(), 'true'), "Whether to send DNS requests over the configured proxy."), ('ssl-strict', SettingValue( typ.BoolAsk(), 'ask'), "Whether to validate SSL handshakes."), ('dns-prefetch', SettingValue(typ.Bool(), 'true'), "Whether to try to pre-fetch DNS entries to speed up browsing."), )), ('completion', sect.KeyValue( ('show', SettingValue(typ.Bool(), 'true'), "Whether to show the autocompletion window."), ('height', SettingValue(typ.PercOrInt(minperc=0, maxperc=100, minint=1), '50%'), "The height of the completion, in px or as percentage of the " "window."), ('history-length', SettingValue(typ.Int(minval=-1), '100'), "How many commands to save in the history.\n\n" "0: no history / -1: unlimited"), ('quick-complete', SettingValue(typ.Bool(), 'true'),