vdirsyncer/tests/system/cli/test_utils.py
Hugo Osvaldo Barrera b1b4dd92fe Sort imports
I don't want to ever have to sort imports again. It's a poor use of
developer time. Automate this with a pre-commit hook, and check this on
CI.

Developers: I suggest you configure your editor to use
`reorder_python_imports`. It uses the standard sorting, and detects
first/third party libs well.
2020-06-09 14:34:45 +02:00

25 lines
790 B
Python

from vdirsyncer import exceptions
from vdirsyncer.cli.utils import handle_cli_error
from vdirsyncer.cli.utils import storage_instance_from_config
from vdirsyncer.cli.utils import storage_names
def test_handle_cli_error(capsys):
try:
raise exceptions.InvalidResponse('ayy lmao')
except BaseException:
handle_cli_error()
out, err = capsys.readouterr()
assert 'returned something vdirsyncer doesn\'t understand' in err
assert 'ayy lmao' in err
def test_storage_instance_from_config(monkeypatch):
def lol(**kw):
assert kw == {'foo': 'bar', 'baz': 1}
return 'OK'
monkeypatch.setitem(storage_names._storages, 'lol', lol)
config = {'type': 'lol', 'foo': 'bar', 'baz': 1}
assert storage_instance_from_config(config) == 'OK'