From 42641c6153a39313db9388bf87ab9ca3fa96c837 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 27 Jul 2013 16:02:59 +0100 Subject: [PATCH] Added test case to see if the usage of `user` and `runas` at the same time raises an exception. --- tests/unit/states/pip_test.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/states/pip_test.py b/tests/unit/states/pip_test.py index fa7a8df604..5fac281b1a 100644 --- a/tests/unit/states/pip_test.py +++ b/tests/unit/states/pip_test.py @@ -19,6 +19,7 @@ ensure_in_syspath('../../') # Import salt libs import integration from salt.states import pip +from salt.exceptions import CommandExecutionError # Import 3rd-party libs try: @@ -61,6 +62,17 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn): 'instead.', {'testsuite': ret} ) + def test_installed_runas_and_user_raises_exception(self): + mock = MagicMock(return_value={'retcode': 0, 'stdout': ''}) + with patch.dict(pip.__salt__, {'cmd.run_all': mock}): + self.assertRaises( + CommandExecutionError, + pip.installed, + 'pep8', + user='Me!', + runas='Not Me!' + ) + def test_removed_deprecated_runas(self): # We *always* want *all* warnings thrown on this module warnings.resetwarnings() @@ -88,7 +100,16 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn): 'instead.', {'testsuite': ret} ) - + def test_removed_runas_and_user_raises_exception(self): + mock = MagicMock(return_value={'retcode': 0, 'stdout': ''}) + with patch.dict(pip.__salt__, {'cmd.run_all': mock}): + self.assertRaises( + CommandExecutionError, + pip.removed, + 'pep8', + user='Me!', + runas='Not Me!' + ) if __name__ == '__main__':