2017-08-09 05:21:03 +02:00
---
- name : Setup test fixture
2017-08-25 02:07:58 +02:00
copy :
src : fixtures/ansible-xml-beers.xml
dest : /tmp/ansible-xml-beers-implicit.xml
2017-08-09 05:21:03 +02:00
- name : Add a phonenumber element to the business element. Implicit mkdir -p behavior where applicable
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/phonenumber
value : 555 -555 -1234
2017-08-09 05:21:03 +02:00
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 1/2
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/owner/name/last
value : Smith
2017-08-09 05:21:03 +02:00
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 2/2
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/owner/name/first
value : John
2017-08-09 05:21:03 +02:00
- 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.
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/website/validxhtml
2017-08-09 05:21:03 +02:00
- 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.
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/website/validxhtml/@validateon
2017-08-09 05:21:03 +02:00
- name : Add an empty validateon attribute to the validxhtml element. Actually verifies the implicit parent-node creation behavior.
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/website_bis/validxhtml/@validateon
2017-08-09 05:21:03 +02:00
- name : Add an attribute with a value
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/owner/@dob='1976-04-12'
2017-08-09 05:21:03 +02:00
- name : Add an element with a value, alternate syntax
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/beers/beer/text()="George Killian's Irish Red" # note the quote within an XPath string thing
2017-08-09 05:21:03 +02:00
- name : Add an element without special characters
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/testnormalelement
value : xml tag with no special characters
pretty_print : yes
2017-08-09 05:21:03 +02:00
- name : Add an element with dash
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with-dash
value : xml tag with dashes
pretty_print : yes
2017-08-09 05:21:03 +02:00
- name : Add an element with dot
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with-dash.and.dot
value : xml tag with dashes and dots
pretty_print : yes
2017-08-09 05:21:03 +02:00
- name : Add an element with underscore
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with.dash_and.dot_and-underscores
value : xml tag with dashes, dots and underscores
pretty_print : yes
2017-08-09 05:21:03 +02:00
- name : Add an attribute on a conditional element
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/beers/beer[text()="George Killian's Irish Red"]/@color='red'
2017-08-09 05:21:03 +02:00
- name : Add two attributes on a conditional element
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/beers/beer[text()="Pilsner Urquell" and @origin='CZ']/@color='blonde'
2017-08-09 05:21:03 +02:00
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 3/2 -- complex lookup
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/owner/name[first/text()='John']/middle
value : Q
2017-08-09 05:21:03 +02:00
- name : Pretty Print this!
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
pretty_print : yes
- name : Compare to expected result
copy :
src : results/test-add-element-implicitly.yml
dest : /tmp/ansible-xml-beers-implicit.xml
check_mode : yes
diff : yes
register : comparison
2017-08-09 05:21:03 +02:00
- name : Test expected result
2017-08-25 02:07:58 +02:00
assert :
that :
- comparison.changed == false # identical
#command: diff -u {{ role_path }}/results/test-add-element-implicitly.yml /tmp/ansible-xml-beers-implicit.xml
2017-08-09 05:21:03 +02:00
2017-08-25 02:07:58 +02:00
# Now we repeat the same, just to ensure proper use of namespaces
2017-08-09 05:21:03 +02:00
- name : Add a phonenumber element to the business element. Implicit mkdir -p behavior where applicable
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:phonenumber
value : 555 -555 -1234
namespaces :
a : http://example.com/some/namespace
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 1/2
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:owner/a:name/a:last
value : Smith
namespaces :
a : http://example.com/some/namespace
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 2/2
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:owner/a:name/a:first
value : John
namespaces :
a : http://example.com/some/namespace
- 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.
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:website/a:validxhtml
namespaces :
a : http://example.com/some/namespace
- 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.
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:website/a:validxhtml/@a:validateon
namespaces :
a : http://example.com/some/namespace
- name : Add an empty validateon attribute to the validxhtml element. Actually verifies the implicit parent-node creation behavior.
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:website_bis/a:validxhtml/@a:validateon
namespaces :
a : http://example.com/some/namespace
- name : Add an attribute with a value
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:owner/@a:dob='1976-04-12'
namespaces :
a : http://example.com/some/namespace
- name : Add an element with a value, alternate syntax
xml :
file : /tmp/ansible-xml-beers-implicit.xml
2017-08-25 02:07:58 +02:00
xpath : /business/a:beers/a:beer/text()="George Killian's Irish Red" # note the quote within an XPath string thing
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add an attribute on a conditional element
xml :
file : /tmp/ansible-xml-beers-implicit.xml
2017-08-25 02:07:58 +02:00
xpath : /business/a:beers/a:beer[text()="George Killian's Irish Red"]/@a:color='red'
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add two attributes on a conditional element
xml :
file : /tmp/ansible-xml-beers-implicit.xml
2017-08-25 02:07:58 +02:00
xpath : /business/a:beers/a:beer[text()="Pilsner Urquell" and @a:origin='CZ']/@a:color='blonde'
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add a owner element to the business element, testing implicit mkdir -p behavior 3/2 -- complex lookup
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/a:owner/a:name[a:first/text()='John']/a:middle
value : Q
namespaces :
a : http://example.com/some/namespace
- name : Add an element without special characters
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/testnormalelement
2017-08-25 02:07:58 +02:00
value : xml tag with no special characters
pretty_print : yes
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add an element with dash
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with-dash
2017-08-25 02:07:58 +02:00
value : xml tag with dashes
pretty_print : yes
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add an element with dot
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with-dash.and.dot
2017-08-25 02:07:58 +02:00
value : xml tag with dashes and dots
pretty_print : yes
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Add an element with underscore
xml :
file : /tmp/ansible-xml-beers-implicit.xml
xpath : /business/test-with.dash_and.dot_and-underscores
2017-08-25 02:07:58 +02:00
value : xml tag with dashes, dots and underscores
pretty_print : yes
2017-08-09 05:21:03 +02:00
namespaces :
a : http://example.com/some/namespace
- name : Pretty Print this!
2017-08-25 02:07:58 +02:00
xml :
file : /tmp/ansible-xml-beers-implicit.xml
pretty_print : yes