| 1 |
--- |
| 2 |
#################################################################### |
| 3 |
# WARNING: These are designed specifically for Ansible tests # |
| 4 |
# and should not be used as examples of how to write Ansible roles # |
| 5 |
#################################################################### |
| 6 |
|
| 7 |
# Copyright (c) Ansible Project |
| 8 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 9 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 10 |
|
| 11 |
- name: Install lxml (FreeBSD) |
| 12 |
package: |
| 13 |
name: 'py{{ ansible_facts.python.version.major }}{{ ansible_facts.python.version.minor }}-lxml' |
| 14 |
state: present |
| 15 |
when: ansible_facts.os_family == "FreeBSD" |
| 16 |
|
| 17 |
- name: Install requirements (RHEL 8) |
| 18 |
package: |
| 19 |
name: |
| 20 |
- libxml2-devel |
| 21 |
- libxslt-devel |
| 22 |
- python3-lxml |
| 23 |
state: present |
| 24 |
when: ansible_facts.distribution == "RedHat" and ansible_facts.distribution_major_version == "8" |
| 25 |
|
| 26 |
# Needed for MacOSX ! |
| 27 |
- name: Install lxml |
| 28 |
pip: |
| 29 |
name: lxml |
| 30 |
state: present |
| 31 |
# when: ansible_facts.os_family == "Darwin" |
| 32 |
|
| 33 |
- name: Get lxml version |
| 34 |
command: "{{ ansible_python_interpreter }} -c 'from lxml import etree; print(\".\".join(str(v) for v in etree.LXML_VERSION))'" |
| 35 |
register: lxml_version |
| 36 |
|
| 37 |
- name: Set lxml capabilities as variables |
| 38 |
set_fact: |
| 39 |
# NOTE: Some tests require predictable element attribute order, |
| 40 |
# which is only guaranteed starting from lxml v3.0alpha1 |
| 41 |
lxml_predictable_attribute_order: '{{ lxml_version.stdout is version("3", ">=") }}' |
| 42 |
|
| 43 |
# NOTE: The xml module requires at least lxml v2.3.0 |
| 44 |
lxml_xpath_attribute_result_attrname: '{{ lxml_version.stdout is version("2.3.0", ">=") }}' |
| 45 |
|
| 46 |
- name: Only run the tests when lxml v2.3.0+ |
| 47 |
when: lxml_xpath_attribute_result_attrname |
| 48 |
block: |
| 49 |
|
| 50 |
- include_tasks: test-add-children-elements.yml |
| 51 |
- include_tasks: test-add-children-from-groupvars.yml |
| 52 |
- include_tasks: test-add-children-insertafter.yml |
| 53 |
- include_tasks: test-add-children-insertbefore.yml |
| 54 |
- include_tasks: test-add-children-with-attributes.yml |
| 55 |
- include_tasks: test-add-element-implicitly.yml |
| 56 |
- include_tasks: test-count.yml |
| 57 |
- include_tasks: test-mutually-exclusive-attributes.yml |
| 58 |
- include_tasks: test-remove-attribute.yml |
| 59 |
- include_tasks: test-remove-attribute-nochange.yml |
| 60 |
- include_tasks: test-remove-element.yml |
| 61 |
- include_tasks: test-remove-element-nochange.yml |
| 62 |
- include_tasks: test-set-attribute-value.yml |
| 63 |
- include_tasks: test-set-attribute-value-boolean.yml |
| 64 |
- include_tasks: test-set-children-elements.yml |
| 65 |
- include_tasks: test-set-children-elements-level.yml |
| 66 |
- include_tasks: test-set-children-elements-value.yml |
| 67 |
- include_tasks: test-set-element-value.yml |
| 68 |
- include_tasks: test-set-element-value-empty.yml |
| 69 |
- include_tasks: test-set-element-value-predicate.yml |
| 70 |
- include_tasks: test-pretty-print.yml |
| 71 |
- include_tasks: test-pretty-print-only.yml |
| 72 |
- include_tasks: test-add-namespaced-children-elements.yml |
| 73 |
- include_tasks: test-remove-namespaced-attribute.yml |
| 74 |
- include_tasks: test-remove-namespaced-attribute-nochange.yml |
| 75 |
- include_tasks: test-set-namespaced-attribute-value.yml |
| 76 |
- include_tasks: test-set-namespaced-element-value.yml |
| 77 |
- include_tasks: test-set-namespaced-children-elements.yml |
| 78 |
- include_tasks: test-get-element-content.yml |
| 79 |
- include_tasks: test-print-match.yml |
| 80 |
- include_tasks: test-xmlstring.yml |
| 81 |
- include_tasks: test-children-elements-xml.yml |
| 82 |
|
| 83 |
# Unicode tests |
| 84 |
- include_tasks: test-add-children-elements-unicode.yml |
| 85 |
- include_tasks: test-add-children-with-attributes-unicode.yml |
| 86 |
- include_tasks: test-set-attribute-value-unicode.yml |
| 87 |
- include_tasks: test-count-unicode.yml |
| 88 |
- include_tasks: test-get-element-content.yml |
| 89 |
- include_tasks: test-set-children-elements-unicode.yml |
| 90 |
- include_tasks: test-set-element-value-unicode.yml |