validations_libs.tests.test_utils module

class validations_libs.tests.test_utils.TestRunCommandAndLog(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_error_subprocess(mock_popen)[source]
test_success_cwd()[source]
test_success_default()[source]
test_success_env()[source]
test_success_no_retcode()[source]
class validations_libs.tests.test_utils.TestUtils(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_ansible_environment_config_load_config()[source]
test_ansible_runner_load_config()[source]
test_check_community_validations_dir_with_missing_subdir(mock_mkdir, mock_iterdir, mock_exists, mock_isdir, mock_log)[source]
test_check_creation_community_validations_dir(mock_mkdir, mock_iterdir, mock_isdir, mock_exists, mock_log)[source]
test_create_artifacts_dir_runtime_err(mock_mkdirs)[source]

Test if failure to create artifacts dir raises ‘RuntimeError’.

test_create_log_dir_access_issue(mock_exists, mock_access, mock_mkdirs, mock_log)[source]
test_create_log_dir_default_perms_runtime_err(mock_exists, mock_access, mock_mkdirs, mock_log)[source]

Test if the inaccessible fallback raises ‘RuntimeError’

test_create_log_dir_existence_issue(mock_exists, mock_access, mock_mkdirs, mock_log)[source]

Tests behavior after encountering non-existence of the the selected log folder, failed attempt to create it (raising PermissionError), and finally resorting to a fallback.

test_create_log_dir_mkdirs(mock_exists, mock_access, mock_mkdirs, mock_log)[source]

Test successful creation of the directory if the first access fails.

test_create_log_dir_runtime_err(mock_exists, mock_access, mock_mkdirs, mock_log)[source]

Test if failure of the fallback raises ‘RuntimeError’

test_create_log_dir_success(mock_exists, mock_access, mock_mkdirs, mock_log)[source]

Test successful log dir retrieval on the first try.

test_default_load_config()[source]
test_eval_types_bool()[source]
test_eval_types_dict()[source]
test_eval_types_int()[source]
test_eval_types_str()[source]
test_get_community_disabled_playbook_by_id(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_community_disabled_validations_data(mock_exists, mock_open, mock_data)[source]

This test is similar to test_get_community_validations_data in the sense that it doesn’t find the validations_commons one and should look for community validations but the setting is disabled by the config so it shouldn’t find any validations

test_get_community_playbook_by_id(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_community_playbook_by_id_not_found(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_community_validations_data(mock_exists, mock_open, mock_data)[source]

The main difference between this test and test_get_validations_data is that this one tries to load first the validations_commons validation then it fails as os.path.exists returns false and then looks for it in the community validations.

test_get_validation_group_name_list(mock_open, mock_load)[source]
test_get_validation_parameters(mock_open, mock_load)[source]
test_get_validations_data(mock_exists, mock_open, mock_data)[source]
test_get_validations_data_wrong_type(mock_exists)[source]
test_get_validations_parameters_no_group(mock_open, mock_load)[source]
test_get_validations_parameters_no_val(mock_open, mock_load)[source]
test_get_validations_parameters_nothing(mock_open, mock_load)[source]
test_get_validations_parameters_wrong_groups_type()[source]
test_get_validations_parameters_wrong_validation_name_type()[source]
test_get_validations_parameters_wrong_validations_data_type()[source]
test_get_validations_playbook_by_category(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_validations_playbook_by_id(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_validations_playbook_by_id_group(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_validations_playbook_by_product(mock_open, mock_load, mock_glob, mock_isfile)[source]
test_get_validations_playbook_group_not_exist(mock_open, mock_load, mock_listdir, mock_isfile)[source]
test_get_validations_playbook_wrong_categories_type()[source]
test_get_validations_playbook_wrong_groups_type()[source]
test_get_validations_playbook_wrong_path_type()[source]
test_get_validations_playbook_wrong_products_type()[source]
test_get_validations_playbook_wrong_validation_id_type()[source]
test_load_config(mock_config, mock_exists)[source]
test_parse_all_community_disabled_validations_on_disk(mock_glob, mock_open, mock_load)[source]
test_parse_all_validations_on_disk(mock_glob, mock_open, mock_load)[source]
test_parse_all_validations_on_disk_by_category(mock_glob, mock_open, mock_load)[source]
test_parse_all_validations_on_disk_by_group(mock_glob, mock_open, mock_load)[source]
test_parse_all_validations_on_disk_by_product(mock_glob, mock_open, mock_load)[source]
test_parse_all_validations_on_disk_wrong_categories_type()[source]
test_parse_all_validations_on_disk_wrong_groups_type()[source]
test_parse_all_validations_on_disk_wrong_path_type()[source]
test_parse_all_validations_on_disk_wrong_products_type()[source]
test_parse_community_validations_on_disk(mock_glob, mock_open, mock_load)[source]
test_read_validation_groups_file(mock_open, mock_load)[source]