From 548b397dbb31cd504b4359874f8879c38ab12769 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 20 Dec 2014 13:50:01 +0100 Subject: [PATCH] Fix a refactoring bug --- tests/test_cli.py | 34 ++++++++++++++++++++++++++++++++++ vdirsyncer/cli/__init__.py | 17 +++++++++-------- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index c6e2b26..cddb31b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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', + ] diff --git a/vdirsyncer/cli/__init__.py b/vdirsyncer/cli/__init__.py index 20a0ca8..418b4db 100644 --- a/vdirsyncer/cli/__init__.py +++ b/vdirsyncer/cli/__init__.py @@ -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()