mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-26 09:05:50 +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('foobar.collections') \
|
||||
.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)
|
||||
|
||||
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:
|
||||
return handle_storage_init_error(cls, config)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue