From: Eric Harney Date: Wed, 18 Feb 2015 18:04:09 +0000 (-0500) Subject: Tests: Fix cxt target tests opening files X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=dead95c68b0fe3fcad84af69cc5e715fabccde22;p=openstack-build%2Fcinder-build.git Tests: Fix cxt target tests opening files This fixes the test_ensure_export test so that it does not try to open files from /var/lib/cinder/. Closes-Bug: #1423261 Change-Id: I79ed64918b2ae7fb5ea8b5cedeb1dca83898c759 --- diff --git a/cinder/tests/targets/test_cxt_driver.py b/cinder/tests/targets/test_cxt_driver.py index 6182348e5..e62af497c 100644 --- a/cinder/tests/targets/test_cxt_driver.py +++ b/cinder/tests/targets/test_cxt_driver.py @@ -195,7 +195,10 @@ class TestCxtAdmDriver(test.TestCase): self.assertTrue(mock_get.called) self.assertTrue(mock_execute.called) - def test_ensure_export(self): + @mock.patch('cinder.volume.targets.cxt.CxtAdm._get_target_chap_auth') + def test_ensure_export(self, mock_get_chap): + fake_creds = ('asdf', 'qwert') + mock_get_chap.return_value = fake_creds ctxt = context.get_admin_context() with mock.patch.object(self.target, 'create_iscsi_target'): self.target.ensure_export(ctxt, @@ -203,6 +206,6 @@ class TestCxtAdmDriver(test.TestCase): self.fake_volumes_dir) self.target.create_iscsi_target.assert_called_once_with( 'iqn.2010-10.org.openstack:testvol', - 1, 0, self.fake_volumes_dir, None, + 1, 0, self.fake_volumes_dir, fake_creds, check_exit_code=False, old_name=None)