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
64673cc9
Commit
64673cc9
authored
May 11, 2012
by
John Kleint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for large output; fix indentation.
parent
0956aa96
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
test/TestRunner.py
+21
-17
No files found.
test/TestRunner.py
View file @
64673cc9
...
...
@@ -78,13 +78,13 @@ class TestRunner(unittest.TestCase):
return
results
[
'contacted'
][
'127.0.0.2'
]
def
test_ping
(
self
):
result
=
self
.
_run
(
'ping'
,
[])
result
=
self
.
_run
(
'ping'
,
[])
assert
"ping"
in
result
def
test_facter
(
self
):
if
not
get_binary
(
"facter"
):
raise
SkipTest
result
=
self
.
_run
(
'facter'
,
[])
result
=
self
.
_run
(
'facter'
,
[])
assert
"hostname"
in
result
# temporarily disbabled since it occasionally hangs
...
...
@@ -99,35 +99,32 @@ class TestRunner(unittest.TestCase):
def
test_copy
(
self
):
# test copy module, change trigger, etc
pass
def
test_copy
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
input_
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
self
.
_get_stage_file
(
'sample.out'
)
assert
not
os
.
path
.
exists
(
output
)
result
=
self
.
_run
(
'copy'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
])
assert
os
.
path
.
exists
(
output
)
data_in
=
file
(
input
)
.
read
()
data_in
=
file
(
input_
)
.
read
()
data_out
=
file
(
output
)
.
read
()
assert
data_in
==
data_out
assert
'failed'
not
in
result
assert
result
[
'changed'
]
==
True
assert
'md5sum'
in
result
result
=
self
.
_run
(
'copy'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
])
assert
result
[
'changed'
]
==
False
def
test_template
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
input_
=
self
.
_get_test_file
(
'sample.j2'
)
metadata
=
self
.
_get_test_file
(
'metadata.json'
)
output
=
self
.
_get_stage_file
(
'sample.out'
)
result
=
self
.
_run
(
'template'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
"metadata=
%
s"
%
metadata
])
...
...
@@ -138,14 +135,13 @@ class TestRunner(unittest.TestCase):
assert
'md5sum'
in
result
assert
'failed'
not
in
result
result
=
self
.
_run
(
'template'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
"metadata=
%
s"
%
metadata
])
assert
result
[
'changed'
]
==
False
def
test_command
(
self
):
# test command module, change trigger, etc
result
=
self
.
_run
(
'command'
,
[
"/bin/echo"
,
"hi"
])
assert
"failed"
not
in
result
...
...
@@ -167,6 +163,14 @@ class TestRunner(unittest.TestCase):
assert
'failed'
not
in
result
assert
result
[
'rc'
]
==
0
def
test_large_output
(
self
):
# Ensure reading a large amount of output from a command doesn't hang.
result
=
self
.
_run
(
'command'
,
[
"/bin/cat"
,
"/usr/share/dict/words"
])
assert
"failed"
not
in
result
assert
"msg"
not
in
result
assert
result
[
'rc'
]
==
0
assert
len
(
result
[
'stdout'
])
>
100000
assert
result
[
'stderr'
]
==
''
def
test_setup
(
self
):
output
=
self
.
_get_stage_file
(
'output.json'
)
...
...
@@ -203,11 +207,11 @@ class TestRunner(unittest.TestCase):
assert
result
[
'ansible_job_id'
]
==
jid
def
test_fetch
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
os
.
path
.
join
(
self
.
stage_dir
,
'127.0.0.2'
,
input
)
result
=
self
.
_run
(
'fetch'
,
[
"src=
%
s"
%
input
,
"dest=
%
s"
%
self
.
stage_dir
])
input_
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
os
.
path
.
join
(
self
.
stage_dir
,
'127.0.0.2'
,
input_
)
result
=
self
.
_run
(
'fetch'
,
[
"src=
%
s"
%
input_
,
"dest=
%
s"
%
self
.
stage_dir
])
assert
os
.
path
.
exists
(
output
)
assert
open
(
input
)
.
read
()
==
open
(
output
)
.
read
()
assert
open
(
input_
)
.
read
()
==
open
(
output
)
.
read
()
def
test_yum
(
self
):
if
not
get_binary
(
"yum"
):
...
...
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