validations_libs.tests.test_ansible module¶
- class validations_libs.tests.test_ansible.TestAnsible(methodName='runTest')[source]¶
Bases:
unittest.case.TestCase
- setUp()[source]¶
Initiates objects needed for testing. Most importantly the Ansible. Also replaces Ansible.log with a MagicMock to check against.
- test_ansible_init(mock_logger)[source]¶
Test of Ansible init. Verifies that uuid atribute is properly set and that the logger has appropriate name assigned.
- test_ansible_runner_error(mock_config, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists, mock_open)[source]¶
- test_check_no_playbook(mock_dump_artifact, mock_exists)[source]¶
Checks if providing nonexistent playbook raises RuntimeError. Checks if os.path.exists is called both with name of the play file and with the path consisting of playbook and directory. Insists on order of the calls. Allows additional calls both before and after the required sequence.
- test_inventory_dict_inventory(mock_yaml_dump, mock_dump_artifact)[source]¶
Test verifies that Ansible._inventory method properly handles inventories provided as dict.
- test_inventory_string_inventory(mock_exists, mock_abspath)[source]¶
This test verifies that Ansible._inventory method properly handles valid inventory file paths.
- test_inventory_wrong_inventory_path(mock_dump_artifact)[source]¶
Test verifies that Ansible._inventory method calls dump_artifact, if supplied by path to a nonexistent inventory file.
- test_run_specific_log_path(moch_path, mock_env, mock_env_var, mock_config, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists, mock_open)[source]¶
- test_run_success_default(mock_config, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists, mock_open)[source]¶
- test_run_success_gathering_policy(mock_config, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists, mock_open)[source]¶
- test_run_success_local(mock_config, mock_open, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists)[source]¶
- test_run_success_run_async(mock_config, mock_open, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists)[source]¶
- test_run_success_with_ansible_config(mock_config, mock_open, mock_dump_artifact, mock_run, mock_mkdirs, mock_exists)[source]¶