Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xml/tasks/test-add-element-implicitly.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-implicit.xml
10
11
12 - name: Add a phonenumber element to the business element. Implicit mkdir -p behavior where applicable
13 xml:
14 file: /tmp/ansible-xml-beers-implicit.xml
15 xpath: /business/phonenumber
16 value: 555-555-1234
17
18 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 1/2
19 xml:
20 file: /tmp/ansible-xml-beers-implicit.xml
21 xpath: /business/owner/name/last
22 value: Smith
23
24 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 2/2
25 xml:
26 file: /tmp/ansible-xml-beers-implicit.xml
27 xpath: /business/owner/name/first
28 value: John
29
30 - name: Add a validxhtml element to the website element. Note that ensure is present by default and while value defaults to null for elements, if one doesn't specify it we don't know what to do.
31 xml:
32 file: /tmp/ansible-xml-beers-implicit.xml
33 xpath: /business/website/validxhtml
34
35 - name: Add an empty validateon attribute to the validxhtml element. This actually makes the previous example redundant because of the implicit parent-node creation behavior.
36 xml:
37 file: /tmp/ansible-xml-beers-implicit.xml
38 xpath: /business/website/validxhtml/@validateon
39
40 - name: Add an empty validateon attribute to the validxhtml element. Actually verifies the implicit parent-node creation behavior.
41 xml:
42 file: /tmp/ansible-xml-beers-implicit.xml
43 xpath: /business/website_bis/validxhtml/@validateon
44
45 - name: Add an attribute with a value
46 xml:
47 file: /tmp/ansible-xml-beers-implicit.xml
48 xpath: /business/owner/@dob='1976-04-12'
49
50 - name: Add an element with a value, alternate syntax
51 xml:
52 file: /tmp/ansible-xml-beers-implicit.xml
53 xpath: /business/beers/beer/text()="George Killian's Irish Red" # note the quote within an XPath string thing
54
55 - name: Add an element without special characters
56 xml:
57 file: /tmp/ansible-xml-beers-implicit.xml
58 xpath: /business/testnormalelement
59 value: xml tag with no special characters
60 pretty_print: true
61
62 - name: Add an element with dash
63 xml:
64 file: /tmp/ansible-xml-beers-implicit.xml
65 xpath: /business/test-with-dash
66 value: xml tag with dashes
67 pretty_print: true
68
69 - name: Add an element with dot
70 xml:
71 file: /tmp/ansible-xml-beers-implicit.xml
72 xpath: /business/test-with-dash.and.dot
73 value: xml tag with dashes and dots
74 pretty_print: true
75
76 - name: Add an element with underscore
77 xml:
78 file: /tmp/ansible-xml-beers-implicit.xml
79 xpath: /business/test-with.dash_and.dot_and-underscores
80 value: xml tag with dashes, dots and underscores
81 pretty_print: true
82
83 - name: Add an attribute on a conditional element
84 xml:
85 file: /tmp/ansible-xml-beers-implicit.xml
86 xpath: /business/beers/beer[text()="George Killian's Irish Red"]/@color='red'
87
88 - name: Add two attributes on a conditional element
89 xml:
90 file: /tmp/ansible-xml-beers-implicit.xml
91 xpath: /business/beers/beer[text()="Pilsner Urquell" and @origin='CZ']/@color='blonde'
92
93 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 3/2 -- complex lookup
94 xml:
95 file: /tmp/ansible-xml-beers-implicit.xml
96 xpath: /business/owner/name[first/text()='John']/middle
97 value: Q
98
99 - name: Pretty Print this!
100 xml:
101 file: /tmp/ansible-xml-beers-implicit.xml
102 pretty_print: true
103
104 - name: Compare to expected result
105 copy:
106 src: results/test-add-element-implicitly.xml
107 dest: /tmp/ansible-xml-beers-implicit.xml
108 check_mode: true
109 diff: true
110 register: comparison
111
112 - name: Test expected result
113 assert:
114 that:
115 - comparison is not changed # identical
116 # command: diff -u {{ role_path }}/results/test-add-element-implicitly.xml /tmp/ansible-xml-beers-implicit.xml
117
118
119 # Now we repeat the same, just to ensure proper use of namespaces
120 - name: Add a phonenumber element to the business element. Implicit mkdir -p behavior where applicable
121 xml:
122 file: /tmp/ansible-xml-beers-implicit.xml
123 xpath: /business/a:phonenumber
124 value: 555-555-1234
125 namespaces:
126 a: http://example.com/some/namespace
127
128 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 1/2
129 xml:
130 file: /tmp/ansible-xml-beers-implicit.xml
131 xpath: /business/a:owner/a:name/a:last
132 value: Smith
133 namespaces:
134 a: http://example.com/some/namespace
135
136 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 2/2
137 xml:
138 file: /tmp/ansible-xml-beers-implicit.xml
139 xpath: /business/a:owner/a:name/a:first
140 value: John
141 namespaces:
142 a: http://example.com/some/namespace
143
144 - name: Add a validxhtml element to the website element. Note that ensure is present by default and while value defaults to null for elements, if one doesn't specify it we don't know what to do.
145 xml:
146 file: /tmp/ansible-xml-beers-implicit.xml
147 xpath: /business/a:website/a:validxhtml
148 namespaces:
149 a: http://example.com/some/namespace
150
151 - name: Add an empty validateon attribute to the validxhtml element. This actually makes the previous example redundant because of the implicit parent-node creation behavior.
152 xml:
153 file: /tmp/ansible-xml-beers-implicit.xml
154 xpath: /business/a:website/a:validxhtml/@a:validateon
155 namespaces:
156 a: http://example.com/some/namespace
157
158 - name: Add an empty validateon attribute to the validxhtml element. Actually verifies the implicit parent-node creation behavior.
159 xml:
160 file: /tmp/ansible-xml-beers-implicit.xml
161 xpath: /business/a:website_bis/a:validxhtml/@a:validateon
162 namespaces:
163 a: http://example.com/some/namespace
164
165 - name: Add an attribute with a value
166 xml:
167 file: /tmp/ansible-xml-beers-implicit.xml
168 xpath: /business/a:owner/@a:dob='1976-04-12'
169 namespaces:
170 a: http://example.com/some/namespace
171
172 - name: Add an element with a value, alternate syntax
173 xml:
174 file: /tmp/ansible-xml-beers-implicit.xml
175 xpath: /business/a:beers/a:beer/text()="George Killian's Irish Red" # note the quote within an XPath string thing
176 namespaces:
177 a: http://example.com/some/namespace
178
179 - name: Add an attribute on a conditional element
180 xml:
181 file: /tmp/ansible-xml-beers-implicit.xml
182 xpath: /business/a:beers/a:beer[text()="George Killian's Irish Red"]/@a:color='red'
183 namespaces:
184 a: http://example.com/some/namespace
185
186 - name: Add two attributes on a conditional element
187 xml:
188 file: /tmp/ansible-xml-beers-implicit.xml
189 xpath: /business/a:beers/a:beer[text()="Pilsner Urquell" and @a:origin='CZ']/@a:color='blonde'
190 namespaces:
191 a: http://example.com/some/namespace
192
193 - name: Add a owner element to the business element, testing implicit mkdir -p behavior 3/2 -- complex lookup
194 xml:
195 file: /tmp/ansible-xml-beers-implicit.xml
196 xpath: /business/a:owner/a:name[a:first/text()='John']/a:middle
197 value: Q
198 namespaces:
199 a: http://example.com/some/namespace
200
201 - name: Add an element without special characters
202 xml:
203 file: /tmp/ansible-xml-beers-implicit.xml
204 xpath: /business/testnormalelement
205 value: xml tag with no special characters
206 pretty_print: true
207 namespaces:
208 a: http://example.com/some/namespace
209
210
211 - name: Add an element with dash
212 xml:
213 file: /tmp/ansible-xml-beers-implicit.xml
214 xpath: /business/test-with-dash
215 value: xml tag with dashes
216 pretty_print: true
217 namespaces:
218 a: http://example.com/some/namespace
219
220 - name: Add an element with dot
221 xml:
222 file: /tmp/ansible-xml-beers-implicit.xml
223 xpath: /business/test-with-dash.and.dot
224 value: xml tag with dashes and dots
225 pretty_print: true
226 namespaces:
227 a: http://example.com/some/namespace
228
229 - name: Add an element with underscore
230 xml:
231 file: /tmp/ansible-xml-beers-implicit.xml
232 xpath: /business/test-with.dash_and.dot_and-underscores
233 value: xml tag with dashes, dots and underscores
234 pretty_print: true
235 namespaces:
236 a: http://example.com/some/namespace
237
238 - name: Pretty Print this!
239 xml:
240 file: /tmp/ansible-xml-beers-implicit.xml
241 pretty_print: true