Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/pipx_info/tasks/main.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Bail out if Python < 3.8
7 when: ansible_facts.python_version is version('3.8', '<')
8 ansible.builtin.meta: end_play
9 - name: Install pipx>=1.7.0
10 ansible.builtin.pip:
11 name: pipx>=1.7.0
12 extra_args: --user
13
14 ##############################################################################
15 - name: Ensure applications are uninstalled
16 community.general.pipx:
17 name: "{{ item }}"
18 state: absent
19 loop:
20 - tox
21 - pylint
22
23 - name: Retrieve applications (empty)
24 community.general.pipx_info: {}
25 register: info_empty
26
27 - name: Install application tox
28 community.general.pipx:
29 name: tox
30
31 - name: Retrieve applications
32 community.general.pipx_info: {}
33 register: info_all
34
35 - name: Retrieve applications (include_deps=true)
36 community.general.pipx_info:
37 include_deps: true
38 register: info_all_deps
39
40 - name: Retrieve application tox
41 community.general.pipx_info:
42 name: tox
43 include_deps: true
44 register: info_tox
45
46 - name: Uninstall application tox
47 community.general.pipx:
48 state: absent
49 name: tox
50
51 - name: Check assertions tox
52 ansible.builtin.assert:
53 that:
54 - info_empty.application|length == 0
55
56 - info_all.application|length == 1
57 - info_all.application[0].name == "tox"
58 - "'version' in info_all.application[0]"
59 - "'dependencies' not in info_all.application[0]"
60 - "'injected' not in info_all.application[0]"
61
62 - info_all_deps.application|length == 1
63 - info_all_deps.application[0].name == "tox"
64 - "'version' in info_all_deps.application[0]"
65 - info_all_deps.application[0].dependencies == ["chardet", "virtualenv"]
66 or info_all_deps.application[0].dependencies == ["virtualenv"]
67 - "'injected' not in info_all.application[0]"
68
69 - info_tox.application == info_all_deps.application
70
71 ##############################################################################
72 - name: Set test applications
73 ansible.builtin.set_fact:
74 apps:
75 - name: tox
76 source: tox==3.24.0
77 - name: pylint
78 inject_packages:
79 - licenses
80
81 - name: Ensure applications are uninstalled
82 community.general.pipx:
83 name: "{{ item.name }}"
84 state: absent
85 loop: "{{ apps }}"
86
87 - name: Install applications
88 community.general.pipx:
89 name: "{{ item.name }}"
90 source: "{{ item.source | default(omit) }}"
91 loop: "{{ apps }}"
92
93 - name: Inject packages
94 community.general.pipx:
95 state: inject
96 name: "{{ item.name }}"
97 inject_packages: "{{ item.inject_packages }}"
98 when: "'inject_packages' in item"
99 loop: "{{ apps }}"
100
101 - name: Retrieve applications
102 community.general.pipx_info: {}
103 register: info2_all
104
105 - name: Retrieve applications (include_deps=true)
106 community.general.pipx_info:
107 include_deps: true
108 include_injected: true
109 register: info2_all_deps
110
111 - name: Retrieve application pylint
112 community.general.pipx_info:
113 name: pylint
114 include_deps: true
115 include_injected: true
116 register: info2_lint
117
118 - name: Ensure applications are uninstalled
119 community.general.pipx:
120 name: "{{ item.name }}"
121 state: absent
122 loop: "{{ apps }}"
123
124 - name: Check assertions multiple apps
125 ansible.builtin.assert:
126 that:
127 - all_apps|length == 2
128 - all_apps[1].name == "tox"
129 - all_apps[1].version == "3.24.0"
130 - "'dependencies' not in all_apps[1]"
131 - "'injected' not in all_apps[1]"
132
133 - all_apps_deps|length == 2
134 - all_apps_deps[1].name == "tox"
135 - all_apps_deps[1].version == "3.24.0"
136 - all_apps_deps[1].dependencies == ["virtualenv"]
137 - "'injected' in all_apps_deps[0]"
138 - "'licenses' in all_apps_deps[0].injected"
139
140 - lint | length == 1
141 - all_apps_deps|length == 2
142 - lint[0] == all_apps_deps[0]
143 vars:
144 all_apps: "{{ info2_all.application | sort(attribute='name') }}"
145 all_apps_deps: "{{ info2_all_deps.application | sort(attribute='name') }}"
146 lint: "{{ info2_lint.application | sort(attribute='name') }}"