summaryrefslogtreecommitdiff
path: root/test/units/playbook
diff options
context:
space:
mode:
authorRick Elrod <rick@elrod.me>2021-04-13 10:22:02 -0500
committerGitHub <noreply@github.com>2021-04-13 11:22:02 -0400
commitbd1acb74c8c3e3587d807b723449ce55d8b99812 (patch)
treea9f69781113bdf83acb7db3a3e8887fd889fc1e0 /test/units/playbook
parent19aeb4706d7f7a984daf2a70f16d69a7dccde484 (diff)
downloadansible-bd1acb74c8c3e3587d807b723449ce55d8b99812.tar.gz
[playbook/play.py] Increase error test coverage (#74217)
Change: - Mostly increase error coverage for various conditions in play.py - Also fix a string in an error, where get_name() was called before self.name was read in, so get_name() was always ''. Test Plan: - new tests Signed-off-by: Rick Elrod <rick@elrod.me> * Fix regex for py2 and py3 Signed-off-by: Rick Elrod <rick@elrod.me> * py2 hates me Signed-off-by: Rick Elrod <rick@elrod.me>
Diffstat (limited to 'test/units/playbook')
-rw-r--r--test/units/playbook/test_play.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/units/playbook/test_play.py b/test/units/playbook/test_play.py
index 725c28eac4..5ce861ea09 100644
--- a/test/units/playbook/test_play.py
+++ b/test/units/playbook/test_play.py
@@ -22,7 +22,7 @@ __metaclass__ = type
from units.compat import unittest
from units.compat.mock import patch, MagicMock
-from ansible.errors import AnsibleParserError
+from ansible.errors import AnsibleAssertionError, AnsibleParserError
from ansible.playbook.play import Play
from units.mock.loader import DictDataLoader
@@ -64,6 +64,14 @@ class TestPlay(unittest.TestCase):
)
self.assertRaises(AnsibleParserError, Play.load, play_data)
+ def test_play_with_bad_ds_type(self):
+ play_data = []
+ self.assertRaisesRegexp(
+ AnsibleAssertionError,
+ r"while preprocessing data \(\[\]\), ds should be a dict but was a <(?:class|type) 'list'>",
+ Play.load,
+ play_data)
+
def test_play_with_tasks(self):
p = Play.load(dict(
name="test play",