Browse Source

Merge "group info test mocks and asserts"

changes/73/790973/3
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
95273322e3
2 changed files with 18 additions and 2 deletions
  1. +16
    -2
      validations_libs/tests/cli/test_show.py
  2. +2
    -0
      validations_libs/tests/fakes.py

+ 16
- 2
validations_libs/tests/cli/test_show.py View File

@ -44,13 +44,27 @@ class TestShowGroup(BaseCommand):
super(TestShowGroup, self).setUp()
self.cmd = show.ShowGroup(self.app, None)
@mock.patch('validations_libs.cli.show.ValidationActions', autospec=True)
@mock.patch('yaml.safe_load', return_value=fakes.GROUP)
@mock.patch('six.moves.builtins.open')
def test_show_validations_group_info(self, mock_open, mock_yaml):
def test_show_validations_group_info(self, mock_open, mock_yaml, mock_actions):
arglist = ['--group', 'group.yaml']
verifylist = [('group', 'group.yaml')]
mock_info = mock.MagicMock()
mock_info.group_information = mock.MagicMock(return_value='foo')
mock_actions.return_value = mock_info
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
group_info = self.cmd.take_action(parsed_args)
mock_actions.assert_called_once_with(
validation_path=fakes.FAKE_VALIDATIONS_PATH)
mock_info.group_information.assert_called_once_with('group.yaml')
self.assertEqual('foo', group_info)
class TestShowParameter(BaseCommand):


+ 2
- 0
validations_libs/tests/fakes.py View File

@ -295,6 +295,8 @@ FAKE_FAILED_RUN = [{'Duration': '0:00:01.761',
'Unreachable_Hosts': '',
'Validations': 'foo'}]
FAKE_VALIDATIONS_PATH = '/usr/share/ansible/validation-playbooks'
def fake_ansible_runner_run_return(status='successful', rc=0):
return status, rc

Loading…
Cancel
Save