diff --git a/molecule/default/tests/conftest.py b/molecule/default/tests/conftest.py deleted file mode 100644 index f7ddb3f..0000000 --- a/molecule/default/tests/conftest.py +++ /dev/null @@ -1,22 +0,0 @@ -"""PyTest Fixtures.""" -from __future__ import absolute_import - -import os - -import pytest - - -def pytest_runtest_setup(item): - """Run tests only when under molecule with testinfra installed.""" - try: - import testinfra - except ImportError: - pytest.skip("Test requires testinfra", allow_module_level=True) - if "MOLECULE_INVENTORY_FILE" in os.environ: - pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] - ).get_hosts("all") - else: - pytest.skip( - "Test should run only from inside molecule.", allow_module_level=True - ) diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py deleted file mode 100644 index a4f6def..0000000 --- a/molecule/default/tests/test_default.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Role testing files using testinfra.""" - - -def test_hosts_file(host): - """Validate /etc/hosts file.""" - etc_hosts = host.file("/etc/hosts") - assert etc_hosts.exists - assert etc_hosts.user == "root" - assert etc_hosts.group == "root" - -def test_python_pip_packages_installed(host): - """Validate python3 and pip are installed""" - apt_package_python3 = host.package("python3") - apt_package_pip = host.package("python3-pip") - assert apt_package_python3.is_installed - assert apt_package_pip.is_installed - -def test_pip_installed_latest(host): - """Validate pip is installed and up-to-date""" - pip_packages_list = host.pip.get_packages(pip_path='pip') - pip_outdated_list = host.pip.get_outdated_packages(pip_path='pip') - assert 'pip' in pip_packages_list - assert 'pip' not in pip_outdated_list - -def test_packages_not_installed(host): - """Validate docker, yamllint and vault-cli are not installed""" - pip_packages_list = host.pip.get_packages(pip_path='pip') - assert 'docker' not in pip_packages_list - assert 'yamllint' not in pip_packages_list - assert 'vault-cli' not in pip_packages_list diff --git a/molecule/with_custom_packages/tests/conftest.py b/molecule/with_custom_packages/tests/conftest.py deleted file mode 100644 index f7ddb3f..0000000 --- a/molecule/with_custom_packages/tests/conftest.py +++ /dev/null @@ -1,22 +0,0 @@ -"""PyTest Fixtures.""" -from __future__ import absolute_import - -import os - -import pytest - - -def pytest_runtest_setup(item): - """Run tests only when under molecule with testinfra installed.""" - try: - import testinfra - except ImportError: - pytest.skip("Test requires testinfra", allow_module_level=True) - if "MOLECULE_INVENTORY_FILE" in os.environ: - pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] - ).get_hosts("all") - else: - pytest.skip( - "Test should run only from inside molecule.", allow_module_level=True - ) diff --git a/molecule/with_custom_packages/tests/test_default.py b/molecule/with_custom_packages/tests/test_default.py deleted file mode 100644 index 66165b2..0000000 --- a/molecule/with_custom_packages/tests/test_default.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Role testing files using testinfra.""" -from packaging import version - - -def test_hosts_file(host): - """Validate /etc/hosts file.""" - etc_hosts = host.file("/etc/hosts") - assert etc_hosts.exists - assert etc_hosts.user == "root" - assert etc_hosts.group == "root" - -def test_python_pip_packages_installed(host): - """Validate python3 and pip are installed""" - apt_package_python3 = host.package("python3") - apt_package_pip = host.package("python3-pip") - assert apt_package_python3.is_installed - assert apt_package_pip.is_installed - -def test_pip_installed_latest(host): - """Validate pip is installed and up-to-date""" - pip_packages_list = host.pip.get_packages(pip_path='pip') - pip_outdated_list = host.pip.get_outdated_packages(pip_path='pip') - assert 'pip' in pip_packages_list - assert 'pip' not in pip_outdated_list - -def test_packages_installed(host): - """Validate docker, yamllint and vault-cli are installed""" - pip_packages_list = host.pip.get_packages(pip_path='pip') - pip_outdated_list = host.pip.get_outdated_packages(pip_path='pip') - assert 'docker' in pip_packages_list - assert 'docker' not in pip_outdated_list - assert 'yamllint' in pip_packages_list - assert 'yamllint' in pip_outdated_list - assert version.parse(pip_packages_list['yamllint']['version']) == version.parse("1.24") - assert 'vault-cli' in pip_packages_list - assert 'vault-cli' in pip_outdated_list - assert version.parse(pip_packages_list['vault-cli']['version']) < version.parse("3.1.0")