mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-26 09:05:50 +00:00
Fix a refactoring bug
This commit is contained in:
parent
7b2bc1bc38
commit
548b397dbb
2 changed files with 43 additions and 8 deletions
|
|
@ -407,3 +407,37 @@ def test_discover_command(tmpdir):
|
|||
env={'VDIRSYNCER_CONFIG': str(cfg)})
|
||||
assert not result.exception
|
||||
assert 'Syncing foobar/d' in result.output
|
||||
|
||||
|
||||
def test_multiple_pairs(tmpdir):
|
||||
cfg_content = [dedent('''
|
||||
[general]
|
||||
status_path = {}/status/
|
||||
''').format(str(tmpdir))]
|
||||
for name_a, name_b in ('foo', 'bar'), ('bam', 'baz'):
|
||||
cfg_content.append(dedent('''
|
||||
[pair {a}{b}]
|
||||
a = {a}
|
||||
b = {b}
|
||||
''').format(a=name_a, b=name_b))
|
||||
|
||||
for name in name_a, name_b:
|
||||
cfg_content.append(dedent('''
|
||||
[storage {name}]
|
||||
type = filesystem
|
||||
path = {base}/{name}/
|
||||
fileext = .txt
|
||||
''').format(name=name, base=str(tmpdir)))
|
||||
|
||||
cfg = tmpdir.join('config')
|
||||
cfg.write(''.join(cfg_content))
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli.app, ['sync'],
|
||||
env={'VDIRSYNCER_CONFIG': str(cfg)})
|
||||
assert sorted(result.output.splitlines()) == [
|
||||
'Discovering collections for pair bambaz',
|
||||
'Discovering collections for pair foobar',
|
||||
'Syncing bambaz',
|
||||
'Syncing foobar',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -105,11 +105,11 @@ def sync(ctx, pairs, force_delete, max_workers):
|
|||
|
||||
for pair_name, collections in parse_pairs_args(pairs, all_pairs):
|
||||
wq.spawn_worker()
|
||||
wq.put(lambda wq: sync_pair(wq, pair_name=pair_name,
|
||||
collections_to_sync=collections,
|
||||
general=general, all_pairs=all_pairs,
|
||||
all_storages=all_storages,
|
||||
force_delete=force_delete))
|
||||
wq.put(functools.partial(sync_pair, pair_name=pair_name,
|
||||
collections_to_sync=collections,
|
||||
general=general, all_pairs=all_pairs,
|
||||
all_storages=all_storages,
|
||||
force_delete=force_delete))
|
||||
|
||||
wq.join()
|
||||
|
||||
|
|
@ -136,11 +136,12 @@ def discover(ctx, pairs, max_workers):
|
|||
.format(pair, list(all_pairs)))
|
||||
|
||||
wq.spawn_worker()
|
||||
wq.put(lambda wq: collections_for_pair(
|
||||
wq.put(functools.partial(
|
||||
(lambda wq, **kwargs: collections_for_pair(**kwargs)),
|
||||
status_path=general['status_path'], name_a=name_a, name_b=name_b,
|
||||
pair_name=pair, config_a=all_storages[name_a],
|
||||
config_b=all_storages[name_b], pair_options=pair_options,
|
||||
skip_cache=True)
|
||||
)
|
||||
skip_cache=True
|
||||
))
|
||||
|
||||
wq.join()
|
||||
|
|
|
|||
Loading…
Reference in a new issue