Download:
child 161:b5837ce0b7a7
parent 159:c233397bcb7e
160:fda1f8cab608
Anton Shestakov <av6@dwimlabs.net>, Mon, 18 Jul 2016 16:04:12 +0800
tests: test utils.lookup_option()

1 файлов изменено, 13 вставок(+), 1 удалений(-) [+]
tests/test_utils.py file | annotate | diff | comparison | revisions
--- a/tests/test_utils.py Mon Jul 18 15:29:51 2016 +0800
+++ b/tests/test_utils.py Mon Jul 18 16:04:12 2016 +0800
@@ -1,9 +1,21 @@
+from argparse import Namespace
from datetime import datetime
-from candolint.utils import parse_timestamp, timestamp
+from candolint.utils import parse_timestamp, timestamp, lookup_option
def test_timestamp_and_parse():
result = parse_timestamp(timestamp())
assert isinstance(result, datetime)
assert result.utcoffset() is None
+
+
+def test_lookup_option():
+ lo = lookup_option
+
+ assert lo('foo', Namespace(), {}, default='maybe') == 'maybe'
+ assert lo('foo', Namespace(foo='yes'), {}, default='maybe') == 'yes'
+ assert lo('foo', Namespace(foo='yes'), {'foo': 'no'}) == 'yes'
+ assert lo('foo', Namespace(), {'foo': 'no'}, default='maybe') == 'no'
+
+ assert lo('a-b-c', Namespace(a_b_c=1), {'a-b-c': 2}, default=3) == 1