tests should cover most ofthe usecases now
This commit is contained in:
parent
cc72967a75
commit
12eedf48e7
@ -15,8 +15,16 @@ def test_python_pip_packages_installed(host):
|
|||||||
assert apt_package_python3.is_installed
|
assert apt_package_python3.is_installed
|
||||||
assert apt_package_pip.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):
|
def test_packages_not_installed(host):
|
||||||
"""Validate vim is installed"""
|
"""Validate docker, yamllint and vault-cli are not installed"""
|
||||||
pip_packages_list = host.pip_package.get_packages(pip_path='pip')
|
pip_packages_list = host.pip.get_packages(pip_path='pip')
|
||||||
print(pip_packages_list)
|
assert 'docker' not in pip_packages_list
|
||||||
assert True == False
|
assert 'yamllint' not in pip_packages_list
|
||||||
|
assert 'vault-cli' not in pip_packages_list
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Role testing files using testinfra."""
|
"""Role testing files using testinfra."""
|
||||||
import json
|
from packaging import version
|
||||||
|
|
||||||
|
|
||||||
def test_hosts_file(host):
|
def test_hosts_file(host):
|
||||||
"""Validate /etc/hosts file."""
|
"""Validate /etc/hosts file."""
|
||||||
@ -15,11 +16,22 @@ def test_python_pip_packages_installed(host):
|
|||||||
assert apt_package_python3.is_installed
|
assert apt_package_python3.is_installed
|
||||||
assert apt_package_pip.is_installed
|
assert apt_package_pip.is_installed
|
||||||
|
|
||||||
def test_packages_not_installed(host):
|
def test_pip_installed_latest(host):
|
||||||
"""Validate vim is installed"""
|
"""Validate pip is installed and up-to-date"""
|
||||||
pip_packages_list = host.pip_package.get_packages(pip_path='pip')
|
pip_packages_list = host.pip.get_packages(pip_path='pip')
|
||||||
assert pip_packages_list['pip']
|
pip_outdated_list = host.pip.get_outdated_packages(pip_path='pip')
|
||||||
assert pip_packages_list['docker']
|
assert 'pip' in pip_packages_list
|
||||||
assert pip_packages_list['zeubi']
|
assert 'pip' not in pip_outdated_list
|
||||||
print(pip_packages_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")
|
||||||
|
@ -11,3 +11,8 @@
|
|||||||
- name: "{{ manage_pip_packages_pip3_package_name }}"
|
- name: "{{ manage_pip_packages_pip3_package_name }}"
|
||||||
version: latest
|
version: latest
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: "Update pip to latest"
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name: pip
|
||||||
|
extra_args: --upgrade
|
||||||
|
Loading…
Reference in New Issue
Block a user