Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
ee9e197f
Commit
ee9e197f
authored
Jun 21, 2013
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the CLI to improve coverage
parent
973260ad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
pyrasite/tests/test_cli.py
pyrasite/tests/test_cli.py
+85
-0
No files found.
pyrasite/tests/test_cli.py
0 → 100644
View file @
ee9e197f
# This file is part of pyrasite.
#
# pyrasite is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyrasite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyrasite. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2013 Red Hat, Inc., Luke Macken <lmacken@redhat.com>
import
os
import
sys
from
StringIO
import
StringIO
from
pyrasite.main
import
main
class
TestCLI
(
object
):
def
test_usage
(
self
):
sys
.
argv
=
[
'pyrasite'
]
try
:
main
()
except
SystemExit
:
exit_code
=
sys
.
exc_value
.
code
assert
exit_code
==
1
,
exit_code
def
test_list_payloads
(
self
):
sys
.
argv
=
[
'pyrasite'
,
'-l'
]
stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
try
:
main
()
except
SystemExit
:
pass
value
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
stdout
assert
'Available payloads:'
in
value
,
repr
(
value
)
assert
'helloworld.py'
in
value
,
repr
(
value
)
def
test_invalid_pid
(
self
):
sys
.
argv
=
[
'pyrasite'
,
'foo'
,
'bar'
]
stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
try
:
main
()
except
SystemExit
:
exit_code
=
sys
.
exc_value
.
code
assert
exit_code
==
2
,
exit_code
value
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
stdout
assert
'Error: The first argument must be a pid'
in
value
,
repr
(
value
)
def
test_invalid_payload
(
self
):
sys
.
argv
=
[
'pyrasite'
,
str
(
os
.
getpid
()),
'foo'
]
stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
try
:
main
()
except
SystemExit
:
exit_code
=
sys
.
exc_value
.
code
assert
exit_code
==
3
,
exit_code
value
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
stdout
assert
"Error: Invalid path or file doesn't exist"
in
value
,
repr
(
value
)
def
test_injection
(
self
):
sys
.
argv
=
[
'pyrasite'
,
str
(
os
.
getpid
()),
'helloworld.py'
]
stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
try
:
main
()
except
SystemExit
:
exit_code
=
sys
.
exc_value
.
code
assert
exit_code
==
4
,
exit_code
value
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
stdout
assert
"Hello World!"
in
value
,
repr
(
value
)
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