Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xml/tasks/test-set-attribute-value-boolean.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 # Regression test for https://github.com/ansible-collections/community.general/issues/7171
7 # Passing an unquoted YAML boolean as `value` must now fail with an explicit error.
8
9 - name: Setup test fixture
10 copy:
11 src: fixtures/ansible-xml-beers.xml
12 dest: /tmp/ansible-xml-beers.xml
13
14
15 - name: "Set '/business/rating/@subjective' to boolean false (unquoted YAML boolean) - must fail"
16 xml:
17 path: /tmp/ansible-xml-beers.xml
18 xpath: /business/rating
19 attribute: subjective
20 value: false
21 register: set_attribute_boolean_false
22 ignore_errors: true
23
24 - name: Assert that passing a boolean attribute value raises an error
25 assert:
26 that:
27 - set_attribute_boolean_false is failed
28 - "'was parsed for' in set_attribute_boolean_false.msg"
29 - "'attribute' in set_attribute_boolean_false.msg"
30
31
32 - name: "Set '/business/rating' text content to boolean true (unquoted YAML boolean) - must fail"
33 xml:
34 path: /tmp/ansible-xml-beers.xml
35 xpath: /business/rating
36 value: true
37 register: set_element_boolean_true
38 ignore_errors: true
39
40 - name: Assert that passing a boolean element value raises an error
41 assert:
42 that:
43 - set_element_boolean_true is failed
44 - "'was parsed for' in set_element_boolean_true.msg"
45 - "'element text' in set_element_boolean_true.msg"
46
47
48 - name: "Set '/business/rating/@subjective' to quoted string 'false' - must succeed"
49 xml:
50 path: /tmp/ansible-xml-beers.xml
51 xpath: /business/rating
52 attribute: subjective
53 value: "false"
54 register: set_attribute_string_false
55
56 - name: Assert that passing a quoted string attribute value succeeds
57 assert:
58 that:
59 - set_attribute_string_false is changed