From 24d6301d92ed4f1f482bbbb68d835c1c1b6a1039 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Tue, 1 May 2018 14:07:17 -0600 Subject: [PATCH] Fix test for netenv validate Previously we were actually attempting to open a file in the NIC_validate function when executed by this test because it was not properly mocked. If you had an empty file /tmp/foo, the test would fail because it would try and read data from it. Change-Id: Iab778b756637ae3e3a4beeea66bfa41b3cedd7b8 Closes-Bug: #1768337 --- .../test_overcloud_netenv_validate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tripleoclient/tests/v1/overcloud_netenv_validate/test_overcloud_netenv_validate.py b/tripleoclient/tests/v1/overcloud_netenv_validate/test_overcloud_netenv_validate.py index 5ac43c462..52fc584f1 100644 --- a/tripleoclient/tests/v1/overcloud_netenv_validate/test_overcloud_netenv_validate.py +++ b/tripleoclient/tests/v1/overcloud_netenv_validate/test_overcloud_netenv_validate.py @@ -13,6 +13,7 @@ # under the License. # +import mock import os import tempfile @@ -257,7 +258,9 @@ class TestValidateOvercloudNetenv(fakes.TestValidateOvercloudNetenv): os.unlink(tmp) self.assertEqual(1, self.cmd.error_count) - def test_command(self): + @mock.patch('tripleoclient.v1.overcloud_netenv_validate.' + 'ValidateOvercloudNetenv.NIC_validate', autospec=True) + def test_command(self, mock_nic_validate): """Testing the command with a minimal file that will fail""" with tempfile.NamedTemporaryFile('wt') as net_file: net_file.write(EMPTY_NETENV)