From 382ed66aa6a671aaa08545e6a4ccad9b5037105e Mon Sep 17 00:00:00 2001 From: Anish Bhatt Date: Tue, 24 Feb 2015 16:14:35 -0800 Subject: [PATCH] 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 --- cinder/tests/targets/test_cxt_driver.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 -- 2.45.2