Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
1c5e918a
Commit
1c5e918a
authored
Mar 06, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add test for slapos console command
parent
fa4f0a11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
slapos/tests/cli.py
slapos/tests/cli.py
+41
-1
No files found.
slapos/tests/cli.py
View file @
1c5e918a
...
...
@@ -28,11 +28,16 @@
import
logging
import
pprint
import
unittest
import
tempfile
import
StringIO
import
sys
from
mock
import
patch
,
create_autospec
import
slapos.cli.list
import
slapos.cli.console
import
slapos.cli.entry
import
slapos.cli.info
import
slapos.cli.list
import
slapos.cli.supervisorctl
from
slapos.client
import
ClientConfig
import
slapos.grid.svcbackend
...
...
@@ -151,3 +156,38 @@ class TestCliSupervisorctl(CliMixin):
slapos
.
cli
.
supervisorctl
.
do_supervisorctl
(
self
.
logger
,
instance_root
,
[
'status'
],
True
)
self
.
assertFalse
(
launchSupervisord
.
called
)
class
TestCliConsole
(
unittest
.
TestCase
):
def
setUp
(
self
):
cp
=
slapos
.
slap
.
ComputerPartition
(
'computer_id'
,
'partition_id'
)
cp
.
_parameter_dict
=
{
'parameter_name'
:
'parameter_value'
}
request_patch
=
patch
.
object
(
slapos
.
slap
.
OpenOrder
,
'request'
,
return_value
=
cp
)
self
.
mock_request
=
request_patch
.
start
()
self
.
config_file
=
tempfile
.
NamedTemporaryFile
()
self
.
config_file
.
write
(
'''[slapos]
master_url=null
'''
)
self
.
config_file
.
flush
()
def
tearDown
(
self
):
self
.
mock_request
.
stop
()
self
.
config_file
.
close
()
def
test_console_interactive
(
self
):
app
=
slapos
.
cli
.
entry
.
SlapOSApp
()
saved_stdin
=
sys
.
stdin
saved_stdout
=
sys
.
stdout
try
:
sys
.
stdin
=
app_stdin
=
StringIO
.
StringIO
(
"""print request('software_release', 'instance').getInstanceParameterDict()['parameter_name']
\
n
"""
)
sys
.
stdout
=
app_stdout
=
StringIO
.
StringIO
()
app
.
run
((
'console'
,
'--cfg'
,
self
.
config_file
.
name
))
finally
:
sys
.
sdin
=
saved_stdin
sys
.
stdout
=
saved_stdout
self
.
mock_request
.
assert_called_once_with
(
'software_release'
,
'instance'
)
self
.
assertIn
(
'parameter_value'
,
app_stdout
.
getvalue
())
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