Skip to content

Commit

Permalink
Fixes tests that use AnsibleUndefined (#383)
Browse files Browse the repository at this point in the history
* Fixes tests that use AnsibleUndefined

* add change log

* add same for other cases
  • Loading branch information
roverflow authored Dec 17, 2024
1 parent 46a3d71 commit dda46ee
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/test_ansibleundefined.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- Fixes test cases where there were assertion failure due to AnsibleUndefined path being changed.
3 changes: 2 additions & 1 deletion tests/unit/plugins/filter/test_ipaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def test_ipaddr_undefined_value(self):
args = ["", AnsibleUndefined(name="my_ip"), ""]
with pytest.raises(
AnsibleFilterError,
match="Unrecognized type <<class 'ansible.template.AnsibleUndefined'>> for ipaddr filter <value>",
# Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15
match=r"Unrecognized type <<class 'ansible\.template\.(native_helpers\.)?AnsibleUndefined'>> for ipaddr filter <value>",
):
_ipaddr(*args)

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/plugins/filter/test_ipv4.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_ipv4_undefined_value(self):
args = ["", AnsibleUndefined(name="my_ip"), ""]
with pytest.raises(
AnsibleFilterError,
match="Unrecognized type <<class 'ansible.template.AnsibleUndefined'>> for ipv4 filter <value>",
# Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15
match=r"Unrecognized type <<class 'ansible\.template\.(native_helpers\.)?AnsibleUndefined'>> for ipv4 filter <value>",
):
_ipv4(*args)

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/plugins/filter/test_ipv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def test_ipv6_undefined_value(self):
args = ["", AnsibleUndefined(name="my_ip"), ""]
with pytest.raises(
AnsibleFilterError,
match="Unrecognized type <<class 'ansible.template.AnsibleUndefined'>> for ipv6 filter <value>",
# Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15
match=r"Unrecognized type <<class 'ansible\.template\.(native_helpers\.)?AnsibleUndefined'>> for ipv6 filter <value>",
):
_ipv6(*args)

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/plugins/filter/test_ipwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_ipwrap_undefined_value(self):
args = ["", AnsibleUndefined(name="my_ip"), ""]
with pytest.raises(
AnsibleFilterError,
match="Unrecognized type <<class 'ansible.template.AnsibleUndefined'>> for ipwrap filter <value>",
# Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15
match=r"Unrecognized type <<class 'ansible\.template\.(native_helpers\.)?AnsibleUndefined'>> for ipwrap filter <value>",
):
_ipwrap(*args)

Expand Down

0 comments on commit dda46ee

Please sign in to comment.