Constants path formatting unification

Paths in the constants.py are now formatted
using a single function, the os.path.join.

This both normalizes the code and reduces
chance of errors and confusion arising
from nonstandard paths.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I761c4449579590b9081a78627eeac754d6b04e2a
This commit is contained in:
Jiri Podivin 2021-05-06 12:01:29 +02:00
parent a55390c21e
commit 803e5b4abf
3 changed files with 12 additions and 6 deletions

View File

@ -18,9 +18,12 @@ DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/ansible/'
ANSIBLE_VALIDATION_DIR = '/usr/share/ansible/validation-playbooks'
VALIDATION_GROUPS_INFO = '%s/groups.yaml' % DEFAULT_VALIDATIONS_BASEDIR
VALIDATION_GROUPS_INFO = os.path.join(
DEFAULT_VALIDATIONS_BASEDIR,
'groups.yaml')
VALIDATIONS_LOG_BASEDIR = os.path.join(os.environ.get('HOME'), 'validations')
VALIDATION_ANSIBLE_ARTIFACT_PATH = '{}/artifacts/'.format(
VALIDATIONS_LOG_BASEDIR)
VALIDATION_ANSIBLE_ARTIFACT_PATH = os.path.join(
VALIDATIONS_LOG_BASEDIR,
'artifacts')

View File

@ -222,6 +222,7 @@ class TestValidationActions(TestCase):
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')

View File

@ -66,7 +66,7 @@ def create_artifacts_dir(log_path=constants.VALIDATIONS_LOG_BASEDIR,
:type log_path: `string`
:param prefix: Playbook name
:type prefix: `string`
:return: The UUID of the validation and the absolute Path of the log file
:return: The UUID of the validation and the absolute path of the log file
:rtype: `string`, `string`
"""
artifact_dir = os.path.join(log_path, 'artifacts')
@ -79,11 +79,13 @@ def create_artifacts_dir(log_path=constants.VALIDATIONS_LOG_BASEDIR,
except (OSError, PermissionError):
LOG.exception(
(
"Error while creating Ansible artifacts log file."
"Please check the access rights for {}"
"Error while creating Ansible artifacts directory. "
"Please check the access rights for: '{}'"
).format(log_dir)
)
raise RuntimeError()
def parse_all_validations_on_disk(path, groups=None):
"""Return a list of validations metadata which can be sorted by Groups