Browse Source

Raise exception if no validation is found

In addition, I have to fix pep8 issue, due to new version

Change-Id: I04728bfdb6473c47c248a4a56bb8df647c51f5ef
(cherry picked from commit ade5d57a3e)
tags/1.0.1
Mathieu Bultel 2 months ago
committed by Emilien Macchi
parent
commit
c744ff2198
2 changed files with 14 additions and 0 deletions
  1. +10
    -0
      validations_libs/tests/test_validation_actions.py
  2. +4
    -0
      validations_libs/validation_actions.py

+ 10
- 0
validations_libs/tests/test_validation_actions.py View File

@@ -81,6 +81,16 @@ class TestValidationActions(TestCase):
validations_dir='/tmp/foo')
self.assertEqual(run_return, expected_run_return)

@mock.patch('validations_libs.utils.get_validations_playbook')
def test_validation_run_wrong_validation_name(self, mock_validation_play):
mock_validation_play.return_value = []

run = ValidationActions()
self.assertRaises(RuntimeError, run.run_validations,
validation_name='fake.yaml',
validations_dir='/tmp/foo'
)

@mock.patch('validations_libs.validation_logs.ValidationLogs.get_results')
@mock.patch('validations_libs.utils.parse_all_validations_on_disk')
@mock.patch('validations_libs.ansible.Ansible.run')


+ 4
- 0
validations_libs/validation_actions.py View File

@@ -88,6 +88,10 @@ class ValidationActions(object):
playbooks = v_utils.get_validations_playbook(validations_dir,
validation_name,
group)
if not playbooks:
msg = "Validation {} not found in {}.".format(validation_name,
validations_dir)
raise RuntimeError(msg)
else:
raise RuntimeError("No validations found")



Loading…
Cancel
Save