ansible-role-borg-backup/molecule/default/tests/test_default.py

34 lines
827 B
Python
Raw Normal View History

"""
Validate host properties using Pytest after Ansible is finished. Uses Testinfra
Possible tests:
- https://testinfra.readthedocs.io/en/latest/modules.html#host
"""
import os
# import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']
).get_hosts('all')
def test_borgmatic_config(host):
f = host.file('/etc/borgmatic/config.yaml')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
# @pytest.mark.parametrize('file, content', [
# ("/etc/firewalld/zones/public.xml", "<service name=\"http\"/>"),
# ("/var/www/html/index.html", "Managed by Ansible")
# ])
# def test_files(host, file, content):
# file = host.file(file)
# assert file.exists
# assert file.contains(content)