Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
63e5ac17
Commit
63e5ac17
authored
Jul 05, 2018
by
juga
Committed by
Matt Traudt
Jul 10, 2018
Browse files
Add unit test for init
parent
72acff55
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/core/test_init.py
0 → 100644
View file @
63e5ac17
"""Unit tests for sbws.core.init."""
import
logging
import
os.path
import
sbws
def
test_sbwshome_only_datadir
(
sbwshome_only_datadir
,
args
,
conf
,
caplog
):
caplog
.
set_level
(
logging
.
DEBUG
)
sbws
.
core
.
init
.
main
(
args
,
conf
)
print
(
caplog
.
records
[
-
1
].
getMessage
())
assert
"Creating {} based on example config"
.
format
(
os
.
path
.
join
(
conf
[
'paths'
][
'sbws_home'
],
'config.ini'
))
\
in
caplog
.
records
[
-
1
].
getMessage
()
assert
os
.
path
.
isdir
(
conf
[
'paths'
][
'sbws_home'
])
assert
os
.
path
.
isdir
(
conf
[
'paths'
][
'datadir'
])
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
conf
[
'paths'
][
'sbws_home'
],
'config.ini'
))
def
test_sbwshome_empty
(
args
,
conf
,
caplog
):
caplog
.
set_level
(
logging
.
DEBUG
)
sbws
.
core
.
init
.
main
(
args
,
conf
)
assert
"Creating {} based on example config"
.
format
(
os
.
path
.
join
(
conf
[
'paths'
][
'sbws_home'
],
'config.ini'
))
\
in
caplog
.
records
[
-
1
].
getMessage
()
assert
os
.
path
.
isdir
(
conf
[
'paths'
][
'sbws_home'
])
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
conf
[
'paths'
][
'sbws_home'
],
'config.ini'
))
def
test_sbwshome
(
sbwshome
,
args
,
conf
,
caplog
):
caplog
.
set_level
(
logging
.
DEBUG
)
try
:
sbws
.
core
.
init
.
main
(
args
,
conf
)
except
SystemExit
as
e
:
assert
e
.
code
==
1
else
:
assert
None
,
'Should have failed'
assert
"Directory already seems to be initted"
\
in
caplog
.
records
[
-
1
].
getMessage
()
assert
os
.
path
.
isdir
(
conf
[
'paths'
][
'sbws_home'
])
assert
os
.
path
.
isdir
(
conf
[
'paths'
][
'datadir'
])
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
conf
[
'paths'
][
'sbws_home'
],
'config.ini'
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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