diff options
Diffstat (limited to 'ansible/roles/resource-data/molecule/default/tests')
-rw-r--r-- | ansible/roles/resource-data/molecule/default/tests/test_default.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ansible/roles/resource-data/molecule/default/tests/test_default.py b/ansible/roles/resource-data/molecule/default/tests/test_default.py new file mode 100644 index 00000000..7cff76a7 --- /dev/null +++ b/ansible/roles/resource-data/molecule/default/tests/test_default.py @@ -0,0 +1,56 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('infrastructure-server') + + +@pytest.fixture +def group_vars(host): + all_file = "file=group_vars/all.yml name=all" + return host.ansible("include_vars", all_file)["ansible_facts"]["all"] + + +@pytest.mark.parametrize('dir', [ + 'app_data_path', + 'aux_data_path' +]) +def test_data_target_dirs(host, dir, group_vars): + tested_dir = host.file(group_vars[dir]) + assert tested_dir.exists + assert tested_dir.is_directory + + +@pytest.mark.parametrize('target_file', [ + 'resource1.txt', + 'resource2.txt', + 'resource3.txt', + 'somedir/resource4.txt' +]) +def test_transferred_resources_files(host, target_file, group_vars): + tested_file = host.file(group_vars["app_data_path"] + "/" + target_file) + assert tested_file.exists + assert tested_file.is_file + + flag_file = \ + host.file(group_vars["app_data_path"] + "/" + + group_vars["resources_filename"] + "-uploaded") + assert flag_file.exists + assert flag_file.is_file + + +@pytest.mark.parametrize('target_file', [ + 'auxdata' +]) +def test_transferred_aux_resources_files(host, target_file, group_vars): + tested_file = host.file(group_vars["aux_data_path"] + "/" + target_file) + assert tested_file.exists + assert tested_file.is_file + + flag_file = \ + host.file(group_vars["aux_data_path"] + "/" + + group_vars["aux_resources_filename"] + "-uploaded") + assert flag_file.exists + assert flag_file.is_file |