Source

thg-qt-mq / commandrunner-test.diff

# HG changeset patch
# Parent a2342b13a00995dda4813c89b812676c965836c7

diff --git a/tests/hglib_command_test.py b/tests/hglib_command_test.py
new file mode 100644
--- /dev/null
+++ b/tests/hglib_command_test.py
@@ -0,0 +1,40 @@
+"""Test for command helper functions of tortoisehg.util.hglib"""
+from nose.tools import *
+from tortoisehg.util import hglib
+
+def test_gencommandargs_noarg():
+    assert_equals(['update'], hglib.gencommandargs('update'))
+
+def test_gencommandargs_pats_opts():
+    assert_equals(['annotate', '--rev', '5', 'foo.txt'],
+                  hglib.gencommandargs('annotate', 'foo.txt', rev=5))
+
+def test_gencommandargs_bool():
+    assert_equals(['email', '--test', 'tip'],
+                  hglib.gencommandargs('email', 'tip', test=True))
+    assert_equals(['email', 'tip'],
+                  hglib.gencommandargs('email', 'tip', test=False))
+
+def test_gencommandargs_none():
+    assert_equals(['update'],
+                  hglib.gencommandargs('update', rev=None))
+    assert_equals(['update', '--rev', '0'],
+                  hglib.gencommandargs('update', rev=0))
+
+def test_gencommandargs_list():
+    assert_equals(['email', '--to', 'foo@bar', '--to', 'baz@blah'],
+                  hglib.gencommandargs('email', to=['foo@bar', 'baz@blah']))
+    assert_equals(['email', '--to', 'foo@bar', '--to', 'baz@blah'],
+                  hglib.gencommandargs('email', to=('foo@bar', 'baz@blah')))
+    assert_equals(['email'],
+                  hglib.gencommandargs('email', to=[]))
+
+def test_gencommandargs_underscore():
+    assert_equals(['serve', '--web-conf', 'foo'],
+                  hglib.gencommandargs('serve', web_conf='foo'))
+
+def test_gencommandargs_repo():
+    assert_equals(['update', '--repository', 'foo'],
+                  hglib.gencommandargs('update', repository='foo'))
+    assert_equals(['update', '--repository', 'foo'],
+                  hglib.gencommandargs('update', R='foo'))