|
|
|
@ -119,7 +119,8 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
|
filename = os.path.join(self.stage_dir, filename)
|
|
|
|
|
return filename
|
|
|
|
|
|
|
|
|
|
def _run(self, test_playbook, host_list='test/ansible_hosts'):
|
|
|
|
|
def _run(self, test_playbook, host_list='test/ansible_hosts',
|
|
|
|
|
extra_vars=None):
|
|
|
|
|
''' run a module and get the localhost results '''
|
|
|
|
|
# This ensures tests are independent of eachother
|
|
|
|
|
global EVENTS
|
|
|
|
@ -135,6 +136,7 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
|
timeout = 5,
|
|
|
|
|
remote_user = self.user,
|
|
|
|
|
remote_pass = None,
|
|
|
|
|
extra_vars = extra_vars,
|
|
|
|
|
stats = ans_callbacks.AggregateStats(),
|
|
|
|
|
callbacks = self.test_callbacks,
|
|
|
|
|
runner_callbacks = self.test_callbacks
|
|
|
|
@ -216,6 +218,29 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
|
|
|
|
|
|
|
|
|
|
def test_templated_includes(self):
|
|
|
|
|
pb = os.path.join(self.test_dir, 'playbook-templated-includer.yml')
|
|
|
|
|
actual = self._run(pb, extra_vars={ 'dir': self.test_dir })
|
|
|
|
|
|
|
|
|
|
# if different, this will output to screen
|
|
|
|
|
print "**ACTUAL**"
|
|
|
|
|
actual_json = utils.jsonify(actual, format=True)
|
|
|
|
|
print actual_json
|
|
|
|
|
expected = {
|
|
|
|
|
"localhost": {
|
|
|
|
|
"changed": 0,
|
|
|
|
|
"failures": 0,
|
|
|
|
|
"ok": 2,
|
|
|
|
|
"skipped": 0,
|
|
|
|
|
"unreachable": 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expected_json = utils.jsonify(expected, format=True)
|
|
|
|
|
print "**EXPECTED**"
|
|
|
|
|
print expected_json
|
|
|
|
|
|
|
|
|
|
assert actual_json == expected_json
|
|
|
|
|
|
|
|
|
|
def test_task_includes(self):
|
|
|
|
|
pb = os.path.join(self.test_dir, 'task-includer.yml')
|
|
|
|
|
actual = self._run(pb)
|
|
|
|
|