Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
43419d7b
Commit
43419d7b
authored
Nov 04, 2012
by
Daniel Hokka Zakrisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for lookup plugins
parent
47082a91
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
test/TestPlayBook.py
+27
-0
test/lookup_plugins.yml
+37
-0
No files found.
test/TestPlayBook.py
View file @
43419d7b
...
...
@@ -113,6 +113,10 @@ class TestPlaybook(unittest.TestCase):
def
_run
(
self
,
test_playbook
,
host_list
=
'test/ansible_hosts'
):
''' run a module and get the localhost results '''
# This ensures tests are independent of eachother
ansible
.
playbook
.
SETUP_CACHE
.
clear
()
EVENTS
=
[]
self
.
test_callbacks
=
TestCallbacks
()
self
.
playbook
=
ansible
.
playbook
.
PlayBook
(
playbook
=
test_playbook
,
...
...
@@ -177,6 +181,29 @@ class TestPlaybook(unittest.TestCase):
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
def
test_lookups
(
self
):
pb
=
os
.
path
.
join
(
self
.
test_dir
,
'lookup_plugins.yml'
)
actual
=
self
.
_run
(
pb
)
# if different, this will output to screen
print
"**ACTUAL**"
print
utils
.
jsonify
(
actual
,
format
=
True
)
expected
=
{
"localhost"
:
{
"changed"
:
7
,
"failures"
:
0
,
"ok"
:
9
,
"skipped"
:
1
,
"unreachable"
:
0
}
}
print
"**EXPECTED**"
print
utils
.
jsonify
(
expected
,
format
=
True
)
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
assert
len
(
EVENTS
)
==
44
def
test_playbook_vars
(
self
):
test_callbacks
=
TestCallbacks
()
playbook
=
ansible
.
playbook
.
PlayBook
(
...
...
test/lookup_plugins.yml
0 → 100644
View file @
43419d7b
# simple test of lookup plugins in with_*
---
-
hosts
:
all
vars
:
empty_list
:
[]
tasks
:
-
name
:
test with_items
action
:
command
true
with_items
:
-
1
-
2
-
3
-
name
:
test with_items with empty list
action
:
command
true
with_items
:
$empty_list
-
name
:
test with_file and FILE
action
:
command test "$item" = "$FILE(sample.j2)"
with_file
:
sample.j2
-
name
:
test with_pipe
action
:
command test "$item" = "$PIPE(cat sample.j2)"
with_pipe
:
cat sample.j2
-
name
:
test LOOKUP and PIPE
action
:
command test "$LOOKUP(pipe, cat sample.j2)" = "$PIPE(cat sample.j2)"
-
name
:
ensure test file doesnt exist
# command because file will return differently
action
:
command rm -f /tmp/ansible-test-with_lines-data
-
name
:
test with_lines
action
:
shell echo "$item" >> /tmp/ansible-test-with_lines-data
with_lines
:
cat sample.j2
-
name
:
verify with_lines
action
:
copy src=sample.j2 dest=/tmp/ansible-test-with_lines-data
-
name
:
cleanup test file
action
:
file path=/tmp/ansible-test-with_lines-data state=absent
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment