summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hellmann <doug.hellmann@dreamhost.com>2013-03-16 13:33:23 -0700
committerDoug Hellmann <doug.hellmann@dreamhost.com>2013-03-16 13:33:23 -0700
commitc3baaff098e3e43323fd77ccef7c4814f9de2cf5 (patch)
treeefa839f489baed04fbd66e73da0facb65744f255
parent18f649c229e025e938241f5c2c15ead57d9d7c4d (diff)
downloadcliff-c3baaff098e3e43323fd77ccef7c4814f9de2cf5.tar.gz
Add tests for underscore handling
Add tests for the convert_underscores option to CommandManager. Change-Id: I5f91bb539bce69936ea86f7a370df2412c3a913c Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
-rw-r--r--tests/test_commandmanager.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_commandmanager.py b/tests/test_commandmanager.py
index 1945f2e..8924405 100644
--- a/tests/test_commandmanager.py
+++ b/tests/test_commandmanager.py
@@ -93,3 +93,27 @@ def test_load_commands():
assert iter_entry_points.called_once_with('test')
names = [n for n, v in mgr]
assert names == ['test']
+
+
+def test_load_commands_keep_underscores():
+ testcmd = mock.Mock()
+ testcmd.name = 'test_cmd'
+ mock_pkg_resources = mock.Mock(return_value=[testcmd])
+ with mock.patch('pkg_resources.iter_entry_points',
+ mock_pkg_resources) as iter_entry_points:
+ mgr = CommandManager('test', convert_underscores=False)
+ assert iter_entry_points.called_once_with('test')
+ names = [n for n, v in mgr]
+ assert names == ['test_cmd']
+
+
+def test_load_commands_replace_underscores():
+ testcmd = mock.Mock()
+ testcmd.name = 'test_cmd'
+ mock_pkg_resources = mock.Mock(return_value=[testcmd])
+ with mock.patch('pkg_resources.iter_entry_points',
+ mock_pkg_resources) as iter_entry_points:
+ mgr = CommandManager('test', convert_underscores=True)
+ assert iter_entry_points.called_once_with('test')
+ names = [n for n, v in mgr]
+ assert names == ['test cmd']