Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xml/tasks/test-get-element-content.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: Get element attributes
13 xml:
14 path: /tmp/ansible-xml-beers.xml
15 xpath: /business/rating
16 content: attribute
17 register: get_element_attribute
18
19 - name: Test expected result
20 assert:
21 that:
22 - get_element_attribute is not changed
23 - get_element_attribute.matches[0]['rating'] is defined
24 - get_element_attribute.matches[0]['rating']['subjective'] == 'true'
25
26 - name: Get element attributes (should fail)
27 xml:
28 path: /tmp/ansible-xml-beers.xml
29 xpath: /business/rating
30 content: attribute
31 attribute: subjective
32 register: get_element_attribute_wrong
33 ignore_errors: true
34
35 - name: Test expected result
36 assert:
37 that:
38 - get_element_attribute_wrong is failed
39
40 - name: Get element text
41 xml:
42 path: /tmp/ansible-xml-beers.xml
43 xpath: /business/rating
44 content: text
45 register: get_element_text
46
47 - name: Test expected result
48 assert:
49 that:
50 - get_element_text is not changed
51 - get_element_text.matches[0]['rating'] == '10'