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
Labels
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
5e2d7e8f
Commit
5e2d7e8f
authored
Aug 24, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: minimal tests for slapos node instance / software
parent
7194013d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
slapos/tests/cli.py
slapos/tests/cli.py
+61
-0
No files found.
slapos/tests/cli.py
View file @
5e2d7e8f
...
...
@@ -33,6 +33,7 @@ import StringIO
import
sys
from
mock
import
patch
,
create_autospec
import
mock
import
slapos.cli.console
import
slapos.cli.entry
...
...
@@ -81,6 +82,66 @@ product2 url2"""
{}
)
class
TestCliNode
(
CliMixin
):
def
test_node_software
(
self
):
"""slapos node software command
"""
app
=
slapos
.
cli
.
entry
.
SlapOSApp
()
software_release
=
mock
.
MagicMock
()
software_release
.
getState
=
mock
.
Mock
(
return_value
=
'available'
)
software_release
.
getURI
=
mock
.
Mock
(
return_value
=
'http://example.org/software.cfg'
)
software_release
.
building
=
mock
.
Mock
()
computer
=
mock
.
MagicMock
()
computer
.
getSoftwareReleaseList
=
mock
.
Mock
(
return_value
=
[
software_release
])
software
=
mock
.
MagicMock
()
from
slapos.grid.slapgrid
import
Slapgrid
from
slapos.slap.slap
import
slap
with
patch
(
'slapos.cli.slapgrid.check_root_user'
,
return_value
=
True
)
as
checked_root_user
,
\
patch
(
'slapos.cli.slapgrid.setRunning'
)
as
write_pid_file
,
\
patch
.
object
(
Slapgrid
,
'checkEnvironmentAndCreateStructure'
)
as
checkEnvironmentAndCreateStructure
,
\
patch
.
object
(
slap
,
'registerComputer'
,
return_value
=
computer
)
as
registerComputer
,
\
patch
(
'slapos.grid.slapgrid.Software'
,
return_value
=
software
)
as
Software
,
\
patch
(
'slapos.grid.slapgrid.open'
)
as
_open
:
app
.
run
((
'node'
,
'software'
))
checked_root_user
.
assert_called_once
()
write_pid_file
.
assert_called_once_with
(
logger
=
mock
.
ANY
,
pidfile
=
'/opt/slapos/slapgrid-sr.pid'
)
checkEnvironmentAndCreateStructure
.
assert_called_once
()
registerComputer
.
assert_called_once
()
software_constructor_call
,
=
Software
.
call_args_list
self
.
assertEqual
(
'http://example.org/software.cfg'
,
software_constructor_call
[
1
][
'url'
])
# by default software are not built in debug mode
self
.
assertFalse
(
software_constructor_call
[
1
][
'buildout_debug'
])
software
.
install
.
assert_called_once
()
def
test_node_instance
(
self
):
"""slapos node instance command
"""
app
=
slapos
.
cli
.
entry
.
SlapOSApp
()
from
slapos.grid.slapgrid
import
Slapgrid
with
patch
(
'slapos.cli.slapgrid.check_root_user'
,
return_value
=
True
)
as
checked_root_user
,
\
patch
(
'slapos.cli.slapgrid.setRunning'
)
as
write_pid_file
,
\
patch
.
object
(
Slapgrid
,
'processComputerPartitionList'
)
as
processComputerPartitionList
:
app
.
run
((
'node'
,
'instance'
))
checked_root_user
.
assert_called_once
()
write_pid_file
.
assert_called_once_with
(
logger
=
mock
.
ANY
,
pidfile
=
'/opt/slapos/slapgrid-cp.pid'
)
processComputerPartitionList
.
assert_called_once
()
class
TestCliList
(
CliMixin
):
def
test_list
(
self
):
"""
...
...
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