1import re
2import os
3
4import testinfra.utils.ansible_runner
5
6testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
7    os.environ['MOLECULE_INVENTORY_FILE']
8).get_hosts('all')
9
10
11def test_hostname(host):
12    assert re.search(r'delegated-instance-docker.*', host.check_output('hostname -s'))
13
14
15def test_etc_molecule_directory(host):
16    f = host.file('/etc/molecule')
17
18    assert f.is_directory
19    assert f.user == 'root'
20    assert f.group == 'root'
21    assert f.mode == 0o755
22
23
24def test_etc_molecule_ansible_hostname_file(host):
25    f = host.file('/etc/molecule/{}'.format(host.check_output('hostname -s')))
26
27    assert f.is_file
28    assert f.user == 'root'
29    assert f.group == 'root'
30    assert f.mode == 0o644
31