From 289ac2cfac8626f8f0db22ccc5bb915d600fb90a Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Wed, 18 Jun 2014 21:32:48 +0200 Subject: [PATCH] More tests --- tests/test_cli.py | 27 ++++++++++++++++++++++----- vdirsyncer/utils/compat.py | 4 ++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 2983ba1..c4d1ecf 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -149,14 +149,15 @@ def test_simple_run(tmpdir): fileext = .txt ''').format(str(tmpdir))) - runner = CliRunner() - result = runner.invoke( - cli.app, ['sync'], - env={'VDIRSYNCER_CONFIG': str(config_file)} - ) + runner = CliRunner(env={'VDIRSYNCER_CONFIG': str(config_file)}) + result = runner.invoke(cli.app, ['sync']) assert not result.exception assert result.output.lower().strip() == 'syncing my_pair' + tmpdir.join('path_a/haha.txt').write('UID:haha') + result = runner.invoke(cli.app, ['sync']) + assert tmpdir.join('path_b/haha.txt').read() == 'UID:haha' + def test_missing_general_section(tmpdir): config_file = tmpdir.join('config') @@ -183,3 +184,19 @@ def test_missing_general_section(tmpdir): ) assert result.exception assert 'critical: unable to find general section' in result.output.lower() + + +def test_verbosity(tmpdir): + runner = CliRunner() + config_file = tmpdir.join('config') + config_file.write(dedent(''' + [general] + status_path = {0}/status/ + ''').format(str(tmpdir))) + + result = runner.invoke( + cli.app, ['--verbosity=HAHA', 'sync'], + env={'VDIRSYNCER_CONFIG': str(config_file)} + ) + assert result.exception + assert 'invalid verbosity value' diff --git a/vdirsyncer/utils/compat.py b/vdirsyncer/utils/compat.py index 94dc822..e088e2d 100644 --- a/vdirsyncer/utils/compat.py +++ b/vdirsyncer/utils/compat.py @@ -12,7 +12,7 @@ import sys PY2 = sys.version_info[0] == 2 -if PY2: +if PY2: # pragma: no cover import urlparse from urllib import \ quote_plus as urlquote_plus, \ @@ -20,7 +20,7 @@ if PY2: text_type = unicode # flake8: noqa iteritems = lambda x: x.iteritems() itervalues = lambda x: x.itervalues() -else: +else: # pragma: no cover import urllib.parse as urlparse urlquote_plus = urlparse.quote_plus urlunquote_plus = urlparse.unquote_plus