Mocking 'open' to improve test isolation

As a result of a minor oversight, the test execution could
initiate a successful call to the 'open' and write in the storage.
This patch addresses the issue.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Iceb6df712b2ac0dc56aa86f465fd39cf308de2d7
This commit is contained in:
Jiri Podivin 2021-11-25 13:28:15 +01:00
parent 1b94c03ee7
commit 1eee81d906

View File

@ -40,10 +40,11 @@ class TestRun(BaseCommand):
parsed_args = self.check_parser(self.cmd, args, verifylist)
self.assertRaises(RuntimeError, self.cmd.take_action, parsed_args)
@mock.patch('validations_libs.cli.common.open')
@mock.patch('validations_libs.validation_actions.ValidationActions.'
'run_validations',
return_value=copy.deepcopy(fakes.FAKE_SUCCESS_RUN))
def test_run_command_success(self, mock_run):
def test_run_command_success(self, mock_run, mock_open):
args = self._set_args(['--validation', 'foo'])
verifylist = [('validation_name', ['foo'])]