From aea94fd6a2a1388565cc7871a3898aac7a0e794f Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 18 Aug 2013 08:03:41 +0100 Subject: [PATCH] Another example test case. --- tests/unit/states/pip_test.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit/states/pip_test.py b/tests/unit/states/pip_test.py index 2fabbca2fc..180895b44c 100644 --- a/tests/unit/states/pip_test.py +++ b/tests/unit/states/pip_test.py @@ -208,6 +208,37 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn): {'test': ret} ) + mock = MagicMock(return_value={'retcode': 0, 'stdout': ''}) + pip_list = MagicMock(return_value={'SaltTesting': '0.5.0'}) + pip_install = MagicMock(return_value={ + 'retcode': 0, + 'stderr' :'', + 'stdout': 'Downloading/unpacking https://pypi.python.org/packages' + '/source/S/SaltTesting/SaltTesting-0.5.0.tar.gz\n ' + 'Downloading SaltTesting-0.5.0.tar.gz\n Running ' + 'setup.py egg_info for package from ' + 'https://pypi.python.org/packages/source/S/SaltTesting/' + 'SaltTesting-0.5.0.tar.gz\n \nCleaning up...' + }) + with patch.dict(pip.__salt__, {'cmd.run_all': mock, + 'pip.list': pip_list, + 'pip.install': pip_install}): + ret = pip.installed( + 'https://pypi.python.org/packages/source/S/SaltTesting/' + 'SaltTesting-0.5.0.tar.gz' + '#md5=e6760af92b7165f8be53b5763e40bc24' + ) + self.assertSaltTrueReturn({'test': ret}) + self.assertInSaltComment( + 'Package was successfully installed', + {'test': ret} + ) + self.assertInSaltReturn( + 'Installed', + {'test': ret}, + ('changes', 'SaltTesting==0.5.0') + ) + if __name__ == '__main__': from integration import run_tests