mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
45cea8f1f3
commit
4742ea61bc
3 changed files with 25 additions and 2 deletions
|
|
@ -10,7 +10,9 @@ from hypothesis.strategies import (
|
||||||
text
|
text
|
||||||
)
|
)
|
||||||
|
|
||||||
from vdirsyncer.cli.utils import coerce_native
|
|
||||||
|
from vdirsyncer import exceptions
|
||||||
|
from vdirsyncer.cli.utils import coerce_native, handle_cli_error
|
||||||
|
|
||||||
|
|
||||||
@given(one_of(
|
@given(one_of(
|
||||||
|
|
@ -24,3 +26,14 @@ from vdirsyncer.cli.utils import coerce_native
|
||||||
))
|
))
|
||||||
def test_coerce_native_fuzzing(s):
|
def test_coerce_native_fuzzing(s):
|
||||||
coerce_native(s)
|
coerce_native(s)
|
||||||
|
|
||||||
|
|
||||||
|
def test_handle_cli_error(capsys):
|
||||||
|
try:
|
||||||
|
raise exceptions.InvalidResponse('ayy lmao')
|
||||||
|
except:
|
||||||
|
handle_cli_error()
|
||||||
|
|
||||||
|
out, err = capsys.readouterr()
|
||||||
|
assert 'returned something vdirsyncer doesn\'t understand' in err
|
||||||
|
assert 'ayy lmao' in err
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ vdirsyncer is a synchronization tool for vdir. See the README for more details.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
PROJECT_HOME = 'https://github.com/pimutils/vdirsyncer'
|
PROJECT_HOME = 'https://github.com/pimutils/vdirsyncer'
|
||||||
|
BUGTRACKER_HOME = PROJECT_HOME + '/issues'
|
||||||
DOCS_HOME = 'https://vdirsyncer.readthedocs.io/en/stable'
|
DOCS_HOME = 'https://vdirsyncer.readthedocs.io/en/stable'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import click
|
||||||
import click_threading
|
import click_threading
|
||||||
|
|
||||||
from . import cli_logger
|
from . import cli_logger
|
||||||
from .. import DOCS_HOME, exceptions
|
from .. import BUGTRACKER_HOME, DOCS_HOME, exceptions
|
||||||
from ..sync import IdentConflict, StorageEmpty, SyncConflict
|
from ..sync import IdentConflict, StorageEmpty, SyncConflict
|
||||||
from ..utils import expand_path, get_storage_init_args
|
from ..utils import expand_path, get_storage_init_args
|
||||||
from ..utils.compat import to_native
|
from ..utils.compat import to_native
|
||||||
|
|
@ -128,6 +128,15 @@ def handle_cli_error(status_name=None):
|
||||||
'configuration file and make sure you\'ve typed the pair name '
|
'configuration file and make sure you\'ve typed the pair name '
|
||||||
'correctly'.format(pair_name=e.pair_name)
|
'correctly'.format(pair_name=e.pair_name)
|
||||||
)
|
)
|
||||||
|
except exceptions.InvalidResponse as e:
|
||||||
|
cli_logger.error(
|
||||||
|
'The server returned something vdirsyncer doesn\'t understand. '
|
||||||
|
'Error message: {!r}\n'
|
||||||
|
'While this is most likely a serverside problem, the vdirsyncer '
|
||||||
|
'devs are generally interested in such bugs. Please report it in '
|
||||||
|
'the issue tracker at {}'
|
||||||
|
.format(e, BUGTRACKER_HOME)
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if status_name:
|
if status_name:
|
||||||
msg = 'Unhandled exception occured for {}.'.format(
|
msg = 'Unhandled exception occured for {}.'.format(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue