From: Anish Bhatt Date: Wed, 25 Feb 2015 00:14:35 +0000 (-0800) Subject: Simplify cxt test_create_export() unit test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=382ed66aa6a671aaa08545e6a4ccad9b5037105e;p=openstack-build%2Fcinder-build.git Simplify cxt test_create_export() unit test Reduce the amount of mocking required by returning a chap tuple directly by mocking _get_target_chap_auth() instead of mocking generate_username and generate_password inside _get_target_chap_auth() Change-Id: I1e6f6c0a538cf3f0be90f8f471522cfe60321a1d --- diff --git a/cinder/tests/targets/test_cxt_driver.py b/cinder/tests/targets/test_cxt_driver.py index e62af497c..bf495554f 100644 --- a/cinder/tests/targets/test_cxt_driver.py +++ b/cinder/tests/targets/test_cxt_driver.py @@ -172,13 +172,12 @@ class TestCxtAdmDriver(test.TestCase): @mock.patch('cinder.volume.targets.cxt.CxtAdm._get_target', return_value=1) @mock.patch('cinder.utils.execute') - @mock.patch('cinder.volume.utils.generate_password', - return_value="P68eE7u9eFqDGexd28DQ") - @mock.patch('cinder.volume.utils.generate_username', - return_value="QZJbisGmn9AL954FNF4D") - def test_create_export(self, mock_user, mock_pass, mock_execute, + @mock.patch.object(cxt.CxtAdm, '_get_target_chap_auth') + def test_create_export(self, mock_chap, mock_execute, mock_get_targ): mock_execute.return_value = ('', '') + mock_chap.return_value = ('QZJbisGmn9AL954FNF4D', + 'P68eE7u9eFqDGexd28DQ') with mock.patch.object(self.target, '_get_volumes_dir') as mock_get: mock_get.return_value = self.fake_volumes_dir