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
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
Paul Graydon
slapos.core
Commits
0c0b92fb
Commit
0c0b92fb
authored
Nov 30, 2018
by
Thomas Gambier
🚴🏼
Committed by
Rafael Monnerat
Dec 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for default argument
parent
9df6ecd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+26
-0
No files found.
slapos/tests/slapformat.py
View file @
0c0b92fb
...
...
@@ -32,6 +32,9 @@ import slapos.format
import
slapos.util
import
slapos.manager.cpuset
import
unittest
from
slapos.cli.format
import
FormatCommand
from
slapos.cli.entry
import
SlapOSApp
from
argparse
import
Namespace
import
netaddr
import
shutil
...
...
@@ -290,6 +293,7 @@ class SlapformatMixin(unittest.TestCase):
self
.
patchPwd
()
self
.
patchNetifaces
()
self
.
patchSlaposUtil
()
self
.
app
=
SlapOSApp
()
def
tearDown
(
self
):
self
.
restoreOs
()
...
...
@@ -887,6 +891,28 @@ class TestSlapformatManagerLifecycle(SlapformatMixin):
self
.
assertEqual
(
manager
.
sequence
,
[
'format'
,
'formatTearDown'
])
class
TestFormatConfig
(
SlapformatMixin
):
def
fake_take_action
(
self
,
args
):
format_command
=
FormatCommand
(
self
.
app
,
Namespace
())
parsed_args
=
format_command
.
get_parser
(
"slapos node format fake"
).
parse_args
(
args
)
configp
=
format_command
.
fetch_config
(
parsed_args
)
conf
=
slapos
.
format
.
FormatConfig
(
logger
=
self
.
logger
)
conf
.
mergeConfig
(
parsed_args
,
configp
)
conf
.
setConfig
()
return
conf
def
test_empty_cmdline_options
(
self
):
conf
=
self
.
fake_take_action
(
""
)
self
.
assertEqual
(
conf
.
alter_network
,
True
)
self
.
assertEqual
(
conf
.
alter_user
,
True
)
def
test_cmdline1_options
(
self
):
conf
=
self
.
fake_take_action
([
"--alter_network"
,
"False"
,
"--alter_user"
,
"True"
])
self
.
assertEqual
(
conf
.
alter_network
,
False
)
self
.
assertEqual
(
conf
.
alter_user
,
True
)
# TODO add more tests with config file
if
__name__
==
'__main__'
:
unittest
.
main
()
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