Permalink
Browse files

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
  • Loading branch information...
anish committed Feb 25, 2015
1 parent 931aaea commit 382ed66aa6a671aaa08545e6a4ccad9b5037105e
Showing with 4 additions and 5 deletions.
  1. +4 −5 cinder/tests/targets/test_cxt_driver.py
@@ -172,13 +172,12 @@ def test_create_iscsi_target_already_exists(self, mock_execute,
@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

0 comments on commit 382ed66

Please sign in to comment.