Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 Mar 4, 2015
1 parent 931aaea commit 382ed66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cinder/tests/targets/test_cxt_driver.py
Expand Up @@ -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

Expand Down

0 comments on commit 382ed66

Please sign in to comment.