mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix a bug in parse_options
This commit is contained in:
parent
745afbe5a3
commit
691abf8c7e
3 changed files with 16 additions and 8 deletions
|
|
@ -21,7 +21,9 @@ def test_parse_options():
|
||||||
'asd': 'off'
|
'asd': 'off'
|
||||||
}
|
}
|
||||||
|
|
||||||
assert dict(utils.parse_options(o.items())) == {
|
a = dict(utils.parse_options(o.items()))
|
||||||
|
|
||||||
|
expected = {
|
||||||
'foo': True,
|
'foo': True,
|
||||||
'hah': True,
|
'hah': True,
|
||||||
'bar': '',
|
'bar': '',
|
||||||
|
|
@ -30,6 +32,11 @@ def test_parse_options():
|
||||||
'asd': False
|
'asd': False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert a == expected
|
||||||
|
|
||||||
|
for key in a:
|
||||||
|
assert type(a[key]) is type(expected[key])
|
||||||
|
|
||||||
|
|
||||||
def test_get_password_from_netrc(monkeypatch):
|
def test_get_password_from_netrc(monkeypatch):
|
||||||
username = 'foouser'
|
username = 'foouser'
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ def prepare_auth(auth, username, password):
|
||||||
|
|
||||||
|
|
||||||
def prepare_verify(verify):
|
def prepare_verify(verify):
|
||||||
if isinstance(verify, bool):
|
if isinstance(verify, (str, unicode)):
|
||||||
return verify
|
return expand_path(verify)
|
||||||
return expand_path(verify)
|
return verify
|
||||||
|
|
||||||
|
|
||||||
class HttpStorageBase(Storage):
|
class HttpStorageBase(Storage):
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,11 @@ def parse_options(items):
|
||||||
value = True
|
value = True
|
||||||
elif value.lower() in ('no', 'false', 'off'):
|
elif value.lower() in ('no', 'false', 'off'):
|
||||||
value = False
|
value = False
|
||||||
try:
|
else:
|
||||||
value = int(value)
|
try:
|
||||||
except ValueError:
|
value = int(value)
|
||||||
pass
|
except ValueError:
|
||||||
|
pass
|
||||||
yield key, value
|
yield key, value
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue