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
ae15060e
Commit
ae15060e
authored
Dec 03, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.format: cleanup
parent
8a67dc7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
slapos/format.py
slapos/format.py
+3
-6
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+10
-9
No files found.
slapos/format.py
View file @
ae15060e
...
...
@@ -1416,7 +1416,7 @@ class FormatConfig(object):
def
checkRequiredBinary
(
binary_list
):
missing_binary_list
=
[]
for
b
in
binary_list
:
if
type
(
b
)
!=
type
([])
:
if
type
(
b
)
is
not
list
:
b
=
[
b
]
try
:
callAndRead
(
b
)
...
...
@@ -1435,13 +1435,10 @@ class FormatConfig(object):
"""
# First, the configuration file options erase the default class options
for
section
in
(
"slapformat"
,
"slapos"
):
configuration_dict
=
dict
(
configp
.
items
(
section
))
for
key
in
configuration_dict
:
setattr
(
self
,
key
,
configuration_dict
[
key
])
self
.
__dict__
.
update
(
configp
.
items
(
section
))
# Second, the command line arguments erase the configuration file options
for
key
,
value
in
args
.
__dict__
.
items
():
setattr
(
self
,
key
,
value
)
self
.
__dict__
.
update
(
args
.
__dict__
)
def
setConfig
(
self
):
# deprecated options raise an error
...
...
slapos/tests/slapformat.py
View file @
ae15060e
...
...
@@ -293,7 +293,6 @@ class SlapformatMixin(unittest.TestCase):
self
.
patchPwd
()
self
.
patchNetifaces
()
self
.
patchSlaposUtil
()
self
.
app
=
SlapOSApp
()
def
tearDown
(
self
):
self
.
restoreOs
()
...
...
@@ -893,8 +892,9 @@ class TestSlapformatManagerLifecycle(SlapformatMixin):
class
TestFormatConfig
(
SlapformatMixin
):
def
fake_take_action
(
self
,
args
):
format_command
=
FormatCommand
(
self
.
app
,
Namespace
())
def
fake_take_action
(
self
,
*
args
):
app
=
SlapOSApp
()
format_command
=
FormatCommand
(
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
)
...
...
@@ -903,14 +903,15 @@ class TestFormatConfig(SlapformatMixin):
return
conf
def
test_empty_cmdline_options
(
self
):
conf
=
self
.
fake_take_action
(
""
)
self
.
assert
Equal
(
conf
.
alter_network
,
True
)
self
.
assert
Equal
(
conf
.
alter_user
,
True
)
conf
=
self
.
fake_take_action
()
self
.
assert
True
(
conf
.
alter_network
)
self
.
assert
True
(
conf
.
alter_user
)
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
)
conf
=
self
.
fake_take_action
(
"--alter_network"
,
"False"
,
"--alter_user"
,
"True"
)
self
.
assertFalse
(
conf
.
alter_network
)
self
.
assertTrue
(
conf
.
alter_user
)
# TODO add more tests with config file
...
...
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