1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
|