Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xml/tasks/test-add-children-with-attributes.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: Setup test fixture
7 copy:
8 src: fixtures/ansible-xml-beers.xml
9 dest: /tmp/ansible-xml-beers.xml
10
11
12 - name: Add child element
13 xml:
14 path: /tmp/ansible-xml-beers.xml
15 xpath: /business/beers
16 add_children:
17 - beer:
18 name: Ansible Brew
19 type: light
20 register: add_children_with_attributes
21
22 - name: Add trailing newline
23 shell: echo "" >> /tmp/ansible-xml-beers.xml
24
25 - name: Compare to expected result
26 copy:
27 src: results/test-add-children-with-attributes.xml
28 dest: /tmp/ansible-xml-beers.xml
29 check_mode: true
30 diff: true
31 register: comparison
32
33 # NOTE: This test may fail if lxml does not support predictable element attribute order
34 # So we filter the failure out for these platforms (e.g. CentOS 6)
35 # The module still works fine, we simply are not comparing as smart as we should.
36 - name: Test expected result
37 assert:
38 that:
39 - add_children_with_attributes is changed
40 - comparison is not changed # identical
41 when: lxml_predictable_attribute_order
42 # command: diff -u {{ role_path }}/results/test-add-children-with-attributes.xml /tmp/ansible-xml-beers.xml