mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Auto merge of #400 - pimutils:not-implemented-discovery, r=untitaker
Nicer output for unsupported discovery Fix #347
This commit is contained in:
commit
45389f87d9
2 changed files with 29 additions and 1 deletions
|
|
@ -60,3 +60,24 @@ def test_discover_command(tmpdir, runner):
|
||||||
.join('status') \
|
.join('status') \
|
||||||
.join('foobar.collections') \
|
.join('foobar.collections') \
|
||||||
.read()
|
.read()
|
||||||
|
|
||||||
|
|
||||||
|
def test_discover_on_unsupported_storage(tmpdir, runner):
|
||||||
|
runner.write_with_general(dedent('''
|
||||||
|
[storage foo]
|
||||||
|
type = http
|
||||||
|
url = https://example.com/foo.ics
|
||||||
|
|
||||||
|
[storage bar]
|
||||||
|
type = memory
|
||||||
|
fileext = .txt
|
||||||
|
|
||||||
|
[pair foobar]
|
||||||
|
a = foo
|
||||||
|
b = bar
|
||||||
|
collections = ["from a"]
|
||||||
|
''').format(str(tmpdir)))
|
||||||
|
|
||||||
|
result = runner.invoke(['discover'])
|
||||||
|
assert result.exception
|
||||||
|
assert 'doesn\'t support collection discovery' in result.output
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,14 @@ def _discover_from_config(config):
|
||||||
cls, config = storage_class_from_config(config)
|
cls, config = storage_class_from_config(config)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
discovered = list(cls.discover(**config))
|
try:
|
||||||
|
discovered = list(cls.discover(**config))
|
||||||
|
except NotImplementedError:
|
||||||
|
raise exceptions.UserError(
|
||||||
|
'The storage {} (type {}) doesn\'t support collection '
|
||||||
|
'discovery. You can only use `collections = null` with it.'
|
||||||
|
.format(config.get('instance_name', '???'), storage_type)
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return handle_storage_init_error(cls, config)
|
return handle_storage_init_error(cls, config)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue