1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/roles/test_pip/tasks/main.yml

119 lines
3.6 KiB
YAML
Raw Normal View History

2014-02-19 21:56:03 +01:00
# test code for the pip module
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# FIXME: replace the python test package
# first some tests installed system-wide
# verify things were not installed to start with
- name: ensure a package is not installed (precondition setup)
pip: name={{ pip_test_package }} state=absent
# verify that a package that is uninstalled being set to absent
# results in an unchanged state and that the test package is not
# installed
- name: ensure a package is not installed
pip: name={{ pip_test_package }} state=absent
register: uninstall_result
- name: removing an unremoved package should return unchanged
assert:
that:
- "not uninstall_result.changed"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
2014-02-19 21:56:03 +01:00
register: absent_result
ignore_errors: True
- name: verify {{ pip_test_package }} is not present
assert:
that:
- "absent_result.rc != 0"
# now we're going to install the test package knowing it is uninstalled
# and check that installation was ok
- name: ensure a package is installed
pip: name={{ pip_test_package }} state=present
register: install_result
- name: verify we recorded a change
assert:
that:
- "install_result.changed == True"
- shell: "{{ ansible_python.executable }} -c 'import {{ pip_test_package }}'"
2014-02-19 21:56:03 +01:00
register: installed_result
# now remove it to test uninstallation of a package we are sure is installed
2014-04-29 16:41:05 +02:00
- name: now uninstall so we can see that a change occurred
2014-02-19 21:56:03 +01:00
pip: name={{ pip_test_package }} state=absent
register: absent2
2014-04-29 16:41:05 +02:00
- name: assert a change occurred on uninstallation
2014-02-19 21:56:03 +01:00
assert:
that:
- "absent2.changed"
# put the test package back
- name: now put it back in case someone wanted it (like us!)
pip: name={{ pip_test_package }} state=present
# Test virtualenv installations
2014-02-19 21:56:03 +01:00
- name: make sure the test env doesn't exist
file: state=absent name={{ output_dir }}/pipenv
2014-02-19 21:56:03 +01:00
- name: create a requirement file with an vcs url
copy: dest={{ output_dir }}/pipreq.txt
content="-e git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
2014-02-19 21:56:03 +01:00
- name: install the requirement file in a virtualenv
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change occurred
assert:
that:
- "req_installed.changed"
- name: repeat installation to check status didn't change
pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv
register: req_installed
- name: check that a change didn't occurr this time (bug ansible#1705)
assert:
that:
- "not req_installed.changed"
- name: install the same module from url
pip: name="git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
virtualenv={{ output_dir }}/pipenv
register: url_installed
- name: check that a change didn't occurr (bug ansible-modules-core#1645)
assert:
that:
- "not url_installed.changed"