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
Titouan Soulard
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):
...
@@ -1416,7 +1416,7 @@ class FormatConfig(object):
def
checkRequiredBinary
(
binary_list
):
def
checkRequiredBinary
(
binary_list
):
missing_binary_list
=
[]
missing_binary_list
=
[]
for
b
in
binary_list
:
for
b
in
binary_list
:
if
type
(
b
)
!=
type
([])
:
if
type
(
b
)
is
not
list
:
b
=
[
b
]
b
=
[
b
]
try
:
try
:
callAndRead
(
b
)
callAndRead
(
b
)
...
@@ -1435,13 +1435,10 @@ class FormatConfig(object):
...
@@ -1435,13 +1435,10 @@ class FormatConfig(object):
"""
"""
# First, the configuration file options erase the default class options
# First, the configuration file options erase the default class options
for
section
in
(
"slapformat"
,
"slapos"
):
for
section
in
(
"slapformat"
,
"slapos"
):
configuration_dict
=
dict
(
configp
.
items
(
section
))
self
.
__dict__
.
update
(
configp
.
items
(
section
))
for
key
in
configuration_dict
:
setattr
(
self
,
key
,
configuration_dict
[
key
])
# Second, the command line arguments erase the configuration file options
# Second, the command line arguments erase the configuration file options
for
key
,
value
in
args
.
__dict__
.
items
():
self
.
__dict__
.
update
(
args
.
__dict__
)
setattr
(
self
,
key
,
value
)
def
setConfig
(
self
):
def
setConfig
(
self
):
# deprecated options raise an error
# deprecated options raise an error
...
...
slapos/tests/slapformat.py
View file @
ae15060e
...
@@ -293,7 +293,6 @@ class SlapformatMixin(unittest.TestCase):
...
@@ -293,7 +293,6 @@ class SlapformatMixin(unittest.TestCase):
self
.
patchPwd
()
self
.
patchPwd
()
self
.
patchNetifaces
()
self
.
patchNetifaces
()
self
.
patchSlaposUtil
()
self
.
patchSlaposUtil
()
self
.
app
=
SlapOSApp
()
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
restoreOs
()
self
.
restoreOs
()
...
@@ -893,8 +892,9 @@ class TestSlapformatManagerLifecycle(SlapformatMixin):
...
@@ -893,8 +892,9 @@ class TestSlapformatManagerLifecycle(SlapformatMixin):
class
TestFormatConfig
(
SlapformatMixin
):
class
TestFormatConfig
(
SlapformatMixin
):
def
fake_take_action
(
self
,
args
):
def
fake_take_action
(
self
,
*
args
):
format_command
=
FormatCommand
(
self
.
app
,
Namespace
())
app
=
SlapOSApp
()
format_command
=
FormatCommand
(
app
,
Namespace
())
parsed_args
=
format_command
.
get_parser
(
"slapos node format fake"
).
parse_args
(
args
)
parsed_args
=
format_command
.
get_parser
(
"slapos node format fake"
).
parse_args
(
args
)
configp
=
format_command
.
fetch_config
(
parsed_args
)
configp
=
format_command
.
fetch_config
(
parsed_args
)
conf
=
slapos
.
format
.
FormatConfig
(
logger
=
self
.
logger
)
conf
=
slapos
.
format
.
FormatConfig
(
logger
=
self
.
logger
)
...
@@ -903,14 +903,15 @@ class TestFormatConfig(SlapformatMixin):
...
@@ -903,14 +903,15 @@ class TestFormatConfig(SlapformatMixin):
return
conf
return
conf
def
test_empty_cmdline_options
(
self
):
def
test_empty_cmdline_options
(
self
):
conf
=
self
.
fake_take_action
(
""
)
conf
=
self
.
fake_take_action
()
self
.
assert
Equal
(
conf
.
alter_network
,
True
)
self
.
assert
True
(
conf
.
alter_network
)
self
.
assert
Equal
(
conf
.
alter_user
,
True
)
self
.
assert
True
(
conf
.
alter_user
)
def
test_cmdline1_options
(
self
):
def
test_cmdline1_options
(
self
):
conf
=
self
.
fake_take_action
([
"--alter_network"
,
"False"
,
"--alter_user"
,
"True"
])
conf
=
self
.
fake_take_action
(
self
.
assertEqual
(
conf
.
alter_network
,
False
)
"--alter_network"
,
"False"
,
"--alter_user"
,
"True"
)
self
.
assertEqual
(
conf
.
alter_user
,
True
)
self
.
assertFalse
(
conf
.
alter_network
)
self
.
assertTrue
(
conf
.
alter_user
)
# TODO add more tests with config file
# 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