diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /test/integration/targets/incidental_xml | |
parent | Initial commit. (diff) | |
download | ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/incidental_xml')
64 files changed, 1885 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_xml/aliases b/test/integration/targets/incidental_xml/aliases new file mode 100644 index 00000000..fc0963c1 --- /dev/null +++ b/test/integration/targets/incidental_xml/aliases @@ -0,0 +1,4 @@ +destructive +shippable/posix/incidental +skip/aix +skip/power/centos diff --git a/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers-unicode.xml b/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers-unicode.xml new file mode 100644 index 00000000..d0e3e39a --- /dev/null +++ b/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers-unicode.xml @@ -0,0 +1,13 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Толстый бар</name> + <beers> + <beer>Окское</beer> + <beer>Невское</beer> + </beers> + <rating subjective="да">десять</rating> + <website> + <mobilefriendly/> + <address>http://tolstyybar.com</address> + </website> +</business> diff --git a/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers.xml b/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers.xml new file mode 100644 index 00000000..5afc7974 --- /dev/null +++ b/test/integration/targets/incidental_xml/fixtures/ansible-xml-beers.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/fixtures/ansible-xml-namespaced-beers.xml b/test/integration/targets/incidental_xml/fixtures/ansible-xml-namespaced-beers.xml new file mode 100644 index 00000000..61747d4b --- /dev/null +++ b/test/integration/targets/incidental_xml/fixtures/ansible-xml-namespaced-beers.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating xmlns="http://test.rating" attr:subjective="true">10</rating> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-children-elements-unicode.xml b/test/integration/targets/incidental_xml/results/test-add-children-elements-unicode.xml new file mode 100644 index 00000000..525330c2 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-elements-unicode.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer>Окское</beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-children-elements.xml b/test/integration/targets/incidental_xml/results/test-add-children-elements.xml new file mode 100644 index 00000000..f9ff2517 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-elements.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer>Old Rasputin</beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-children-from-groupvars.xml b/test/integration/targets/incidental_xml/results/test-add-children-from-groupvars.xml new file mode 100644 index 00000000..565ba402 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-from-groupvars.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer>Natty Lite</beer><beer>Miller Lite</beer><beer>Coors Lite</beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-children-insertafter.xml b/test/integration/targets/incidental_xml/results/test-add-children-insertafter.xml new file mode 100644 index 00000000..8da96336 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-insertafter.xml @@ -0,0 +1,17 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Old Rasputin</beer> + <beer>Old Motor Oil</beer> + <beer>Old Curmudgeon</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business> diff --git a/test/integration/targets/incidental_xml/results/test-add-children-insertbefore.xml b/test/integration/targets/incidental_xml/results/test-add-children-insertbefore.xml new file mode 100644 index 00000000..c409e54b --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-insertbefore.xml @@ -0,0 +1,17 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>Old Rasputin</beer> + <beer>Old Motor Oil</beer> + <beer>Old Curmudgeon</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business> diff --git a/test/integration/targets/incidental_xml/results/test-add-children-with-attributes-unicode.xml b/test/integration/targets/incidental_xml/results/test-add-children-with-attributes-unicode.xml new file mode 100644 index 00000000..37465224 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-with-attributes-unicode.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer name="Окское" type="экстра"/></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-children-with-attributes.xml b/test/integration/targets/incidental_xml/results/test-add-children-with-attributes.xml new file mode 100644 index 00000000..5a3907f6 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-children-with-attributes.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer name="Ansible Brew" type="light"/></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-add-element-implicitly.yml b/test/integration/targets/incidental_xml/results/test-add-element-implicitly.yml new file mode 100644 index 00000000..fa1ddfca --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-element-implicitly.yml @@ -0,0 +1,32 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer color="red">George Killian's Irish Red</beer> + <beer origin="CZ" color="blonde">Pilsner Urquell</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + <validxhtml validateon=""/> + </website> + <phonenumber>555-555-1234</phonenumber> + <owner dob="1976-04-12"> + <name> + <last>Smith</last> + <first>John</first> + <middle>Q</middle> + </name> + </owner> + <website_bis> + <validxhtml validateon=""/> + </website_bis> + <testnormalelement>xml tag with no special characters</testnormalelement> + <test-with-dash>xml tag with dashes</test-with-dash> + <test-with-dash.and.dot>xml tag with dashes and dots</test-with-dash.and.dot> + <test-with.dash_and.dot_and-underscores>xml tag with dashes, dots and underscores</test-with.dash_and.dot_and-underscores> +</business> diff --git a/test/integration/targets/incidental_xml/results/test-add-namespaced-children-elements.xml b/test/integration/targets/incidental_xml/results/test-add-namespaced-children-elements.xml new file mode 100644 index 00000000..3d27e8aa --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-add-namespaced-children-elements.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer>Old Rasputin</beer></beers> + <rating xmlns="http://test.rating" attr:subjective="true">10</rating> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-pretty-print-only.xml b/test/integration/targets/incidental_xml/results/test-pretty-print-only.xml new file mode 100644 index 00000000..f47909ac --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-pretty-print-only.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business> diff --git a/test/integration/targets/incidental_xml/results/test-pretty-print.xml b/test/integration/targets/incidental_xml/results/test-pretty-print.xml new file mode 100644 index 00000000..b5c38262 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-pretty-print.xml @@ -0,0 +1,15 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + <beer>Old Rasputin</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business> diff --git a/test/integration/targets/incidental_xml/results/test-remove-attribute.xml b/test/integration/targets/incidental_xml/results/test-remove-attribute.xml new file mode 100644 index 00000000..8a621cf1 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-remove-attribute.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating>10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-remove-element.xml b/test/integration/targets/incidental_xml/results/test-remove-element.xml new file mode 100644 index 00000000..454d905c --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-remove-element.xml @@ -0,0 +1,13 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-remove-namespaced-attribute.xml b/test/integration/targets/incidental_xml/results/test-remove-namespaced-attribute.xml new file mode 100644 index 00000000..732a0ed2 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-remove-namespaced-attribute.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating xmlns="http://test.rating">10</rating> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-remove-namespaced-element.xml b/test/integration/targets/incidental_xml/results/test-remove-namespaced-element.xml new file mode 100644 index 00000000..16df98e2 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-remove-namespaced-element.xml @@ -0,0 +1,13 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-attribute-value-unicode.xml b/test/integration/targets/incidental_xml/results/test-set-attribute-value-unicode.xml new file mode 100644 index 00000000..de3bc3f6 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-attribute-value-unicode.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="нет">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-attribute-value.xml b/test/integration/targets/incidental_xml/results/test-set-attribute-value.xml new file mode 100644 index 00000000..143fe7bf --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-attribute-value.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="false">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-children-elements-level.xml b/test/integration/targets/incidental_xml/results/test-set-children-elements-level.xml new file mode 100644 index 00000000..0ef2b7e6 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-children-elements-level.xml @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer alcohol="0.5" name="90 Minute IPA"><Water liter="0.2" quantity="200g"/><Starch quantity="10g"/><Hops quantity="50g"/><Yeast quantity="20g"/></beer><beer alcohol="0.3" name="Harvest Pumpkin Ale"><Water liter="0.2" quantity="200g"/><Hops quantity="25g"/><Yeast quantity="20g"/></beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-children-elements-unicode.xml b/test/integration/targets/incidental_xml/results/test-set-children-elements-unicode.xml new file mode 100644 index 00000000..f19d5356 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-children-elements-unicode.xml @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Окское</beer><beer>Невское</beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-children-elements.xml b/test/integration/targets/incidental_xml/results/test-set-children-elements.xml new file mode 100644 index 00000000..be313a5a --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-children-elements.xml @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>90 Minute IPA</beer><beer>Harvest Pumpkin Ale</beer></beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-element-value-empty.xml b/test/integration/targets/incidental_xml/results/test-set-element-value-empty.xml new file mode 100644 index 00000000..785beb64 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-element-value-empty.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">10</rating> + <website> + <mobilefriendly/> + <address></address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-element-value-unicode.xml b/test/integration/targets/incidental_xml/results/test-set-element-value-unicode.xml new file mode 100644 index 00000000..734fe6db --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-element-value-unicode.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">пять</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +<rating>пять</rating></business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-element-value.xml b/test/integration/targets/incidental_xml/results/test-set-element-value.xml new file mode 100644 index 00000000..fc97ec3b --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-element-value.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business type="bar"> + <name>Tasty Beverage Co.</name> + <beers> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating subjective="true">5</rating> + <website> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +<rating>5</rating></business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-namespaced-attribute-value.xml b/test/integration/targets/incidental_xml/results/test-set-namespaced-attribute-value.xml new file mode 100644 index 00000000..44abda43 --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-namespaced-attribute-value.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating xmlns="http://test.rating" attr:subjective="false">10</rating> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/results/test-set-namespaced-element-value.xml b/test/integration/targets/incidental_xml/results/test-set-namespaced-element-value.xml new file mode 100644 index 00000000..0cc8a79e --- /dev/null +++ b/test/integration/targets/incidental_xml/results/test-set-namespaced-element-value.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='UTF-8'?> +<business xmlns="http://test.business" xmlns:attr="http://test.attribute" type="bar"> + <name>Tasty Beverage Co.</name> + <beers xmlns="http://test.beers"> + <beer>Rochefort 10</beer> + <beer>St. Bernardus Abbot 12</beer> + <beer>Schlitz</beer> + </beers> + <rating xmlns="http://test.rating" attr:subjective="true">11</rating> + <website xmlns="http://test.website"> + <mobilefriendly/> + <address>http://tastybeverageco.com</address> + </website> +</business>
\ No newline at end of file diff --git a/test/integration/targets/incidental_xml/tasks/main.yml b/test/integration/targets/incidental_xml/tasks/main.yml new file mode 100644 index 00000000..9b8f2c36 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/main.yml @@ -0,0 +1,67 @@ +- name: Gather facts + setup: + +- name: Install lxml (FreeBSD) + package: + name: '{{ "py27-lxml" if ansible_python.version.major == 2 else "py36-lxml" }}' + state: present + when: ansible_os_family == "FreeBSD" + +# Needed for MacOSX ! +- name: Install lxml + pip: + name: lxml + state: present +# when: ansible_os_family == "Darwin" + +- name: Get lxml version + command: "{{ ansible_python_interpreter }} -c 'from lxml import etree; print(\".\".join(str(v) for v in etree.LXML_VERSION))'" + register: lxml_version + +- name: Set lxml capabilities as variables + set_fact: + # NOTE: Some tests require predictable element attribute order, + # which is only guaranteed starting from lxml v3.0alpha1 + lxml_predictable_attribute_order: '{{ lxml_version.stdout is version("3", ">=") }}' + + # NOTE: The xml module requires at least lxml v2.3.0 + lxml_xpath_attribute_result_attrname: '{{ lxml_version.stdout is version("2.3.0", ">=") }}' + +- name: Only run the tests when lxml v2.3.0+ + when: lxml_xpath_attribute_result_attrname + block: + + - include_tasks: test-add-children-elements.yml + - include_tasks: test-add-children-from-groupvars.yml + - include_tasks: test-add-children-insertafter.yml + - include_tasks: test-add-children-insertbefore.yml + - include_tasks: test-add-children-with-attributes.yml + - include_tasks: test-add-element-implicitly.yml + - include_tasks: test-count.yml + - include_tasks: test-mutually-exclusive-attributes.yml + - include_tasks: test-remove-attribute.yml + - include_tasks: test-remove-element.yml + - include_tasks: test-set-attribute-value.yml + - include_tasks: test-set-children-elements.yml + - include_tasks: test-set-children-elements-level.yml + - include_tasks: test-set-element-value.yml + - include_tasks: test-set-element-value-empty.yml + - include_tasks: test-pretty-print.yml + - include_tasks: test-pretty-print-only.yml + - include_tasks: test-add-namespaced-children-elements.yml + - include_tasks: test-remove-namespaced-attribute.yml + - include_tasks: test-set-namespaced-attribute-value.yml + - include_tasks: test-set-namespaced-element-value.yml + - include_tasks: test-set-namespaced-children-elements.yml + - include_tasks: test-get-element-content.yml + - include_tasks: test-xmlstring.yml + - include_tasks: test-children-elements-xml.yml + + # Unicode tests + - include_tasks: test-add-children-elements-unicode.yml + - include_tasks: test-add-children-with-attributes-unicode.yml + - include_tasks: test-set-attribute-value-unicode.yml + - include_tasks: test-count-unicode.yml + - include_tasks: test-get-element-content.yml + - include_tasks: test-set-children-elements-unicode.yml + - include_tasks: test-set-element-value-unicode.yml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-elements-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-elements-unicode.yml new file mode 100644 index 00000000..8ad91501 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-elements-unicode.yml @@ -0,0 +1,29 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + add_children: + - beer: Окское + register: add_children_elements_unicode + + - name: Compare to expected result + copy: + src: results/test-add-children-elements-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_elements_unicode.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-children-elements-unicode.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-elements.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-elements.yml new file mode 100644 index 00000000..8d9b0686 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-elements.yml @@ -0,0 +1,29 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + add_children: + - beer: Old Rasputin + register: add_children_elements + + - name: Compare to expected result + copy: + src: results/test-add-children-elements.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_elements.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-children-elements.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-from-groupvars.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-from-groupvars.yml new file mode 100644 index 00000000..e062de8d --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-from-groupvars.yml @@ -0,0 +1,28 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + add_children: '{{ bad_beers }}' + register: add_children_from_groupvars + + - name: Compare to expected result + copy: + src: results/test-add-children-from-groupvars.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_from_groupvars.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-children-from-groupvars.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-insertafter.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-insertafter.yml new file mode 100644 index 00000000..2d42e2d5 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-insertafter.yml @@ -0,0 +1,32 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: '/business/beers/beer[text()="St. Bernardus Abbot 12"]' + insertafter: yes + add_children: + - beer: Old Rasputin + - beer: Old Motor Oil + - beer: Old Curmudgeon + pretty_print: yes + register: add_children_insertafter + + - name: Compare to expected result + copy: + src: results/test-add-children-insertafter.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_insertafter.changed == true + - comparison.changed == false # identical diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-insertbefore.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-insertbefore.yml new file mode 100644 index 00000000..8550f12c --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-insertbefore.yml @@ -0,0 +1,32 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: '/business/beers/beer[text()="St. Bernardus Abbot 12"]' + insertbefore: yes + add_children: + - beer: Old Rasputin + - beer: Old Motor Oil + - beer: Old Curmudgeon + pretty_print: yes + register: add_children_insertbefore + + - name: Compare to expected result + copy: + src: results/test-add-children-insertbefore.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_insertbefore.changed == true + - comparison.changed == false # identical diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes-unicode.yml new file mode 100644 index 00000000..d4a2329f --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes-unicode.yml @@ -0,0 +1,31 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + add_children: + - beer: + name: Окское + type: экстра + register: add_children_with_attributes_unicode + + - name: Compare to expected result + copy: + src: results/test-add-children-with-attributes-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_children_with_attributes_unicode.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-children-with-attributes-unicode.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes.yml b/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes.yml new file mode 100644 index 00000000..91e92637 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-children-with-attributes.yml @@ -0,0 +1,35 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + add_children: + - beer: + name: Ansible Brew + type: light + register: add_children_with_attributes + + - name: Compare to expected result + copy: + src: results/test-add-children-with-attributes.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + # NOTE: This test may fail if lxml does not support predictable element attribute order + # So we filter the failure out for these platforms (e.g. CentOS 6) + # The module still works fine, we simply are not comparing as smart as we should. + - name: Test expected result + assert: + that: + - add_children_with_attributes.changed == true + - comparison.changed == false # identical + when: lxml_predictable_attribute_order + #command: diff -u {{ role_path }}/results/test-add-children-with-attributes.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-add-element-implicitly.yml b/test/integration/targets/incidental_xml/tasks/test-add-element-implicitly.yml new file mode 100644 index 00000000..db674ba4 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-element-implicitly.yml @@ -0,0 +1,237 @@ +--- +- name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers-implicit.xml + + +- 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/phonenumber + value: 555-555-1234 + +- 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/owner/name/last + value: Smith + +- 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/owner/name/first + value: John + +- 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/website/validxhtml + +- 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/website/validxhtml/@validateon + +- 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/website_bis/validxhtml/@validateon + +- name: Add an attribute with a value + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/owner/@dob='1976-04-12' + +- name: Add an element with a value, alternate syntax + 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 + +- name: Add an element without special characters + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/testnormalelement + value: xml tag with no special characters + pretty_print: yes + +- name: Add an element with dash + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/test-with-dash + value: xml tag with dashes + pretty_print: yes + +- name: Add an element with dot + 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 + +- name: Add an element with underscore + 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 + +- name: Add an attribute on a conditional element + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/beers/beer[text()="George Killian's Irish Red"]/@color='red' + +- name: Add two attributes on a conditional element + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/beers/beer[text()="Pilsner Urquell" and @origin='CZ']/@color='blonde' + +- 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/owner/name[first/text()='John']/middle + value: Q + +- name: Pretty Print this! + 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 + +- name: Test expected result + assert: + that: + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-element-implicitly.yml /tmp/ansible-xml-beers-implicit.xml + + +# Now we repeat the same, just to ensure proper use of namespaces +- 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 + xpath: /business/a:beers/a:beer/text()="George Killian's Irish Red" # note the quote within an XPath string thing + namespaces: + a: http://example.com/some/namespace + +- name: Add an attribute on a conditional element + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/a:beers/a:beer[text()="George Killian's Irish Red"]/@a:color='red' + namespaces: + a: http://example.com/some/namespace + +- name: Add two attributes on a conditional element + xml: + file: /tmp/ansible-xml-beers-implicit.xml + xpath: /business/a:beers/a:beer[text()="Pilsner Urquell" and @a:origin='CZ']/@a:color='blonde' + 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 + value: xml tag with no special characters + pretty_print: yes + 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 + value: xml tag with dashes + pretty_print: yes + 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 + value: xml tag with dashes and dots + pretty_print: yes + 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 + value: xml tag with dashes, dots and underscores + pretty_print: yes + namespaces: + a: http://example.com/some/namespace + +- name: Pretty Print this! + xml: + file: /tmp/ansible-xml-beers-implicit.xml + pretty_print: yes diff --git a/test/integration/targets/incidental_xml/tasks/test-add-namespaced-children-elements.yml b/test/integration/targets/incidental_xml/tasks/test-add-namespaced-children-elements.yml new file mode 100644 index 00000000..25eca47f --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-add-namespaced-children-elements.yml @@ -0,0 +1,32 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + + + - name: Add namespaced child element + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + xpath: /bus:business/ber:beers + namespaces: + bus: http://test.business + ber: http://test.beers + add_children: + - beer: Old Rasputin + register: add_namespaced_children_elements + + - name: Compare to expected result + copy: + src: results/test-add-namespaced-children-elements.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - add_namespaced_children_elements.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-namespaced-children-elements.xml /tmp/ansible-xml-namespaced-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-children-elements-xml.yml b/test/integration/targets/incidental_xml/tasks/test-children-elements-xml.yml new file mode 100644 index 00000000..e63100c4 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-children-elements-xml.yml @@ -0,0 +1,30 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element with xml format + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + input_type: xml + add_children: + - '<beer>Old Rasputin</beer>' + register: children_elements + + - name: Compare to expected result + copy: + src: results/test-add-children-elements.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - children_elements.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-add-children-elements.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-count-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-count-unicode.yml new file mode 100644 index 00000000..47a806bf --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-count-unicode.yml @@ -0,0 +1,19 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers-unicode.xml + dest: /tmp/ansible-xml-beers-unicode.xml + + + - name: Count child element + xml: + path: /tmp/ansible-xml-beers-unicode.xml + xpath: /business/beers/beer + count: yes + register: beers + + - name: Test expected result + assert: + that: + - beers.changed == false + - beers.count == 2 diff --git a/test/integration/targets/incidental_xml/tasks/test-count.yml b/test/integration/targets/incidental_xml/tasks/test-count.yml new file mode 100644 index 00000000..cbc97e32 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-count.yml @@ -0,0 +1,19 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add child element + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers/beer + count: yes + register: beers + + - name: Test expected result + assert: + that: + - beers.changed == false + - beers.count == 3 diff --git a/test/integration/targets/incidental_xml/tasks/test-get-element-content-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-get-element-content-unicode.yml new file mode 100644 index 00000000..73ae9667 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-get-element-content-unicode.yml @@ -0,0 +1,32 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers-unicode.xml + dest: /tmp/ansible-xml-beers-unicode.xml + + + - name: Get element attributes + xml: + path: /tmp/ansible-xml-beers-unicode.xml + xpath: /business/rating + content: attribute + register: get_element_attribute + + - name: Test expected result + assert: + that: + - get_element_attribute.changed == false + - get_element_attribute.matches[0]['rating'] is defined and get_element_attribute.matches[0]['rating']['subjective'] == 'да' + + - name: Get element text + xml: + path: /tmp/ansible-xml-beers-unicode.xml + xpath: /business/rating + content: text + register: get_element_text + + - name: Test expected result + assert: + that: + - get_element_text.changed == false + - get_element_text.matches[0]['rating'] == 'десять' diff --git a/test/integration/targets/incidental_xml/tasks/test-get-element-content.yml b/test/integration/targets/incidental_xml/tasks/test-get-element-content.yml new file mode 100644 index 00000000..58ca7767 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-get-element-content.yml @@ -0,0 +1,52 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Get element attributes + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + content: attribute + register: get_element_attribute + + - name: Test expected result + assert: + that: + - get_element_attribute.changed == false + - get_element_attribute.matches[0]['rating'] is defined + - get_element_attribute.matches[0]['rating']['subjective'] == 'true' + + # TODO: Remove this in Ansible v2.12 when this incorrect use of attribute is deprecated + - name: Get element attributes + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + content: attribute + attribute: subjective + register: get_element_attribute_wrong + + - name: Test expected result + assert: + that: + - get_element_attribute_wrong.changed == false + - get_element_attribute_wrong.matches[0]['rating'] is defined + - get_element_attribute_wrong.matches[0]['rating']['subjective'] == 'true' + - get_element_attribute_wrong.deprecations is defined + - get_element_attribute_wrong.deprecations[0].msg == "Parameter 'attribute=subjective' is ignored when using 'content=attribute' only 'xpath' is used. Please remove entry." + - get_element_attribute_wrong.deprecations[0].version == '2.12' + + - name: Get element text + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + content: text + register: get_element_text + + - name: Test expected result + assert: + that: + - get_element_text.changed == false + - get_element_text.matches[0]['rating'] == '10' diff --git a/test/integration/targets/incidental_xml/tasks/test-mutually-exclusive-attributes.yml b/test/integration/targets/incidental_xml/tasks/test-mutually-exclusive-attributes.yml new file mode 100644 index 00000000..3f24b0ac --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-mutually-exclusive-attributes.yml @@ -0,0 +1,22 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Specify both children to add and a value + xml: + path: /tmp/ansible-xml-beers.xml + add_children: + - child01 + - child02 + value: conflict! + register: module_output + ignore_errors: yes + + - name: Test expected result + assert: + that: + - module_output.changed == false + - module_output.failed == true diff --git a/test/integration/targets/incidental_xml/tasks/test-pretty-print-only.yml b/test/integration/targets/incidental_xml/tasks/test-pretty-print-only.yml new file mode 100644 index 00000000..7c0f7d5f --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-pretty-print-only.yml @@ -0,0 +1,29 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml.orig + + - name: Remove spaces from test fixture + shell: sed 's/^[ ]*//g' < /tmp/ansible-xml-beers.xml.orig > /tmp/ansible-xml-beers.xml + + - name: Pretty print without modification + xml: + path: /tmp/ansible-xml-beers.xml + pretty_print: yes + register: pretty_print_only + + - name: Compare to expected result + copy: + src: results/test-pretty-print-only.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - pretty_print_only.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-pretty-print.yml b/test/integration/targets/incidental_xml/tasks/test-pretty-print.yml new file mode 100644 index 00000000..88b618b2 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-pretty-print.yml @@ -0,0 +1,30 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Pretty print + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + pretty_print: yes + add_children: + - beer: Old Rasputin + register: pretty_print + + - name: Compare to expected result + copy: + src: results/test-pretty-print.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - pretty_print.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-pretty-print.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-remove-attribute.yml b/test/integration/targets/incidental_xml/tasks/test-remove-attribute.yml new file mode 100644 index 00000000..9aa395e6 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-remove-attribute.yml @@ -0,0 +1,28 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Remove '/business/rating/@subjective' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating/@subjective + state: absent + register: remove_attribute + + - name: Compare to expected result + copy: + src: results/test-remove-attribute.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - remove_attribute.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-remove-attribute.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-remove-element.yml b/test/integration/targets/incidental_xml/tasks/test-remove-element.yml new file mode 100644 index 00000000..f2e20ea2 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-remove-element.yml @@ -0,0 +1,28 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Remove '/business/rating' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + state: absent + register: remove_element + + - name: Compare to expected result + copy: + src: results/test-remove-element.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - remove_element.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-remove-element.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-attribute.yml b/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-attribute.yml new file mode 100644 index 00000000..36682b22 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-attribute.yml @@ -0,0 +1,33 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + + + - name: Remove namespaced '/bus:business/rat:rating/@attr:subjective' + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + xpath: /bus:business/rat:rating/@attr:subjective + namespaces: + bus: http://test.business + ber: http://test.beers + rat: http://test.rating + attr: http://test.attribute + state: absent + register: remove_namespaced_attribute + + - name: Compare to expected result + copy: + src: results/test-remove-namespaced-attribute.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - remove_element.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-remove-namespaced-attribute.xml /tmp/ansible-xml-namespaced-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-element.yml b/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-element.yml new file mode 100644 index 00000000..be78af68 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-remove-namespaced-element.yml @@ -0,0 +1,33 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + + + - name: Remove namespaced '/bus:business/rat:rating' + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + xpath: /bus:business/rat:rating + namespaces: + bus: http://test.business + ber: http://test.beers + rat: http://test.rating + attr: http://test.attribute + state: absent + register: remove_namespaced_element + + - name: Compare to expected result + copy: + src: results/test-remove-element.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - remove_namespaced_element.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-remove-element.xml /tmp/ansible-xml-namespaced-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-attribute-value-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-set-attribute-value-unicode.yml new file mode 100644 index 00000000..dabf72a1 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-attribute-value-unicode.yml @@ -0,0 +1,29 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set '/business/rating/@subjective' to 'нет' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + attribute: subjective + value: нет + register: set_attribute_value_unicode + + - name: Compare to expected result + copy: + src: results/test-set-attribute-value-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_attribute_value_unicode.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-attribute-value-unicode.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-attribute-value.yml b/test/integration/targets/incidental_xml/tasks/test-set-attribute-value.yml new file mode 100644 index 00000000..2aa39fe2 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-attribute-value.yml @@ -0,0 +1,29 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set '/business/rating/@subjective' to 'false' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + attribute: subjective + value: 'false' + register: set_attribute_value + + - name: Compare to expected result + copy: + src: results/test-set-attribute-value.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_attribute_value.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-attribute-value.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-children-elements-level.yml b/test/integration/targets/incidental_xml/tasks/test-set-children-elements-level.yml new file mode 100644 index 00000000..3e2c0adb --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-children-elements-level.yml @@ -0,0 +1,74 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set child elements + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: &children + - beer: + alcohol: "0.5" + name: 90 Minute IPA + _: + - Water: + liter: "0.2" + quantity: 200g + - Starch: + quantity: 10g + - Hops: + quantity: 50g + - Yeast: + quantity: 20g + - beer: + alcohol: "0.3" + name: Harvest Pumpkin Ale + _: + - Water: + liter: "0.2" + quantity: 200g + - Hops: + quantity: 25g + - Yeast: + quantity: 20g + register: set_children_elements_level + + - name: Compare to expected result + copy: + src: results/test-set-children-elements-level.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_elements_level.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements-level.xml /tmp/ansible-xml-beers.xml + + + - name: Set child elements (again) + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: *children + register: set_children_again + + - name: Compare to expected result + copy: + src: results/test-set-children-elements-level.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_again.changed == false + - comparison.changed == false # identical diff --git a/test/integration/targets/incidental_xml/tasks/test-set-children-elements-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-set-children-elements-unicode.yml new file mode 100644 index 00000000..240b894a --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-children-elements-unicode.yml @@ -0,0 +1,46 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set child elements + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: &children + - beer: Окское + - beer: Невское + register: set_children_elements_unicode + + - name: Compare to expected result + copy: + src: results/test-set-children-elements-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_elements_unicode.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements-unicode.xml /tmp/ansible-xml-beers.xml + + + - name: Compare to expected result + copy: + src: results/test-set-children-elements-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_again.changed == false + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements-unicode.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-children-elements.yml b/test/integration/targets/incidental_xml/tasks/test-set-children-elements.yml new file mode 100644 index 00000000..7b0f3247 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-children-elements.yml @@ -0,0 +1,53 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set child elements + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: &children + - beer: 90 Minute IPA + - beer: Harvest Pumpkin Ale + register: set_children_elements + + - name: Compare to expected result + copy: + src: results/test-set-children-elements.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_elements.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements.xml /tmp/ansible-xml-beers.xml + + + - name: Set child elements (again) + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/beers + set_children: *children + register: set_children_again + + - name: Compare to expected result + copy: + src: results/test-set-children-elements.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_children_again.changed == false + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-children-elements.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-element-value-empty.yml b/test/integration/targets/incidental_xml/tasks/test-set-element-value-empty.yml new file mode 100644 index 00000000..5814803c --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-element-value-empty.yml @@ -0,0 +1,28 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Set '/business/website/address' to empty string. + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/website/address + value: '' + register: set_element_value_empty + + - name: Compare to expected result + copy: + src: results/test-set-element-value-empty.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_element_value_empty.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-element-value-empty.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-element-value-unicode.yml b/test/integration/targets/incidental_xml/tasks/test-set-element-value-unicode.yml new file mode 100644 index 00000000..c3a40b7d --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-element-value-unicode.yml @@ -0,0 +1,43 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add 2nd '/business/rating' with value 'пять' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business + add_children: + - rating: пять + + - name: Set '/business/rating' to 'пять' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + value: пять + register: set_element_first_run + + - name: Set '/business/rating' to 'false'... again + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + value: пять + register: set_element_second_run + + - name: Compare to expected result + copy: + src: results/test-set-element-value-unicode.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_element_first_run.changed == true + - set_element_second_run.changed == false + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-element-value-unicode.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-element-value.yml b/test/integration/targets/incidental_xml/tasks/test-set-element-value.yml new file mode 100644 index 00000000..dbd070f1 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-element-value.yml @@ -0,0 +1,43 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-beers.xml + dest: /tmp/ansible-xml-beers.xml + + + - name: Add 2nd '/business/rating' with value '5' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business + add_children: + - rating: '5' + + - name: Set '/business/rating' to '5' + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + value: '5' + register: set_element_first_run + + - name: Set '/business/rating' to '5'... again + xml: + path: /tmp/ansible-xml-beers.xml + xpath: /business/rating + value: '5' + register: set_element_second_run + + - name: Compare to expected result + copy: + src: results/test-set-element-value.xml + dest: /tmp/ansible-xml-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_element_first_run.changed == true + - set_element_second_run.changed == false + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-element-value.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-namespaced-attribute-value.yml b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-attribute-value.yml new file mode 100644 index 00000000..e0086efe --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-attribute-value.yml @@ -0,0 +1,34 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + + + - name: Set namespaced '/bus:business/rat:rating/@attr:subjective' to 'false' + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + xpath: /bus:business/rat:rating + namespaces: + bus: http://test.business + ber: http://test.beers + rat: http://test.rating + attr: http://test.attribute + attribute: attr:subjective + value: 'false' + register: set_namespaced_attribute_value + + - name: Compare to expected result + copy: + src: results/test-set-namespaced-attribute-value.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - set_namespaced_attribute_value.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-set-namespaced-attribute-value.xml /tmp/ansible-xml-namespaced-beers.xml diff --git a/test/integration/targets/incidental_xml/tasks/test-set-namespaced-children-elements.yml b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-children-elements.yml new file mode 100644 index 00000000..8e66e70e --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-children-elements.yml @@ -0,0 +1,57 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers-xml.xml + + - name: Set child elements + xml: + path: /tmp/ansible-xml-namespaced-beers-xml.xml + xpath: /bus:business/ber:beers + namespaces: + bus: http://test.business + ber: http://test.beers + set_children: + - beer: 90 Minute IPA + - beer: Harvest Pumpkin Ale + + - name: Copy state after first set_children + copy: + src: /tmp/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers-1.xml + remote_src: yes + + - name: Set child elements again + xml: + path: /tmp/ansible-xml-namespaced-beers-xml.xml + xpath: /bus:business/ber:beers + namespaces: + bus: http://test.business + ber: http://test.beers + set_children: + - beer: 90 Minute IPA + - beer: Harvest Pumpkin Ale + register: set_children_again + + - name: Copy state after second set_children + copy: + src: /tmp/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers-2.xml + remote_src: yes + + - name: Compare to expected result + copy: + src: /tmp/ansible-xml-namespaced-beers-1.xml + dest: /tmp/ansible-xml-namespaced-beers-2.xml + remote_src: yes + check_mode: yes + diff: yes + register: comparison + #command: diff /tmp/ansible-xml-namespaced-beers-1.xml /tmp/ansible-xml-namespaced-beers-2.xml + + - name: Test expected result + assert: + that: + - set_children_again.changed == false # idempotency + - set_namespaced_attribute_value.changed == true + - comparison.changed == false # identical diff --git a/test/integration/targets/incidental_xml/tasks/test-set-namespaced-element-value.yml b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-element-value.yml new file mode 100644 index 00000000..f77d7537 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-set-namespaced-element-value.yml @@ -0,0 +1,46 @@ +--- + - name: Setup test fixture + copy: + src: fixtures/ansible-xml-namespaced-beers.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + + + - name: Set namespaced '/bus:business/rat:rating' to '11' + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + namespaces: + bus: http://test.business + ber: http://test.beers + rat: http://test.rating + attr: http://test.attribute + xpath: /bus:business/rat:rating + value: '11' + register: set_element_first_run + + - name: Set namespaced '/bus:business/rat:rating' to '11' again + xml: + path: /tmp/ansible-xml-namespaced-beers.xml + namespaces: + bus: http://test.business + ber: http://test.beers + rat: http://test.rating + attr: http://test.attribute + xpath: /bus:business/rat:rating + value: '11' + register: set_element_second_run + + - name: Compare to expected result + copy: + src: results/test-set-namespaced-element-value.xml + dest: /tmp/ansible-xml-namespaced-beers.xml + check_mode: yes + diff: yes + register: comparison + #command: diff -u {{ role_path }}/results/test-set-namespaced-element-value.xml /tmp/ansible-xml-namespaced-beers.xml + + - name: Test expected result + assert: + that: + - set_element_first_run.changed == true + - set_element_second_run.changed == false + - comparison.changed == false # identical diff --git a/test/integration/targets/incidental_xml/tasks/test-xmlstring.yml b/test/integration/targets/incidental_xml/tasks/test-xmlstring.yml new file mode 100644 index 00000000..4620d984 --- /dev/null +++ b/test/integration/targets/incidental_xml/tasks/test-xmlstring.yml @@ -0,0 +1,81 @@ +--- + - name: Copy expected results to remote + copy: + src: "results/{{ item }}" + dest: "/tmp/{{ item }}" + with_items: + - test-pretty-print.xml + - test-pretty-print-only.xml + + # NOTE: Jinja2 templating eats trailing newlines + - name: Read from xmlstring (not using pretty_print) + xml: + xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}" + xpath: . + register: xmlresponse + + - name: Compare to expected result + copy: + content: "{{ xmlresponse.xmlstring }}\n" + dest: '/tmp/test-pretty-print-only.xml' + check_mode: yes + diff: yes + register: comparison + + - name: Test expected result + assert: + that: + - xmlresponse.changed == false + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml + + + # NOTE: Jinja2 templating eats trailing newlines + - name: Read from xmlstring (using pretty_print) + xml: + xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}" + pretty_print: yes + register: xmlresponse + + - name: Compare to expected result + copy: + content: '{{ xmlresponse.xmlstring }}' + dest: '/tmp/test-pretty-print-only.xml' + check_mode: yes + diff: yes + register: comparison + + # FIXME: This change is related to the newline added by pretty_print + - name: Test expected result + assert: + that: + - xmlresponse.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-pretty-print-only.xml /tmp/ansible-xml-beers.xml + + + # NOTE: Jinja2 templating eats trailing newlines + - name: Read from xmlstring + xml: + xmlstring: "{{ lookup('file', '{{ role_path }}/fixtures/ansible-xml-beers.xml') }}" + xpath: /business/beers + pretty_print: yes + add_children: + - beer: Old Rasputin + register: xmlresponse_modification + + - name: Compare to expected result + copy: + content: '{{ xmlresponse_modification.xmlstring }}' + dest: '/tmp/test-pretty-print.xml' + check_mode: yes + diff: yes + register: comparison + + # FIXME: This change is related to the newline added by pretty_print + - name: Test expected result + assert: + that: + - xmlresponse_modification.changed == true + - comparison.changed == false # identical + #command: diff -u {{ role_path }}/results/test-pretty-print.xml /tmp/ansible-xml-beers.xml diff --git a/test/integration/targets/incidental_xml/vars/main.yml b/test/integration/targets/incidental_xml/vars/main.yml new file mode 100644 index 00000000..7c5675bd --- /dev/null +++ b/test/integration/targets/incidental_xml/vars/main.yml @@ -0,0 +1,6 @@ +# -*- mode: yaml -* +--- +bad_beers: +- beer: "Natty Lite" +- beer: "Miller Lite" +- beer: "Coors Lite" |