Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Trevor Cappallo
OperationalLogging
Commits
8915716c
Commit
8915716c
authored
Aug 19, 2015
by
Trevor Cappallo
Browse files
fix load config, add unit test
parent
2bc81d8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
lib/OperationalLogger.py
lib/OperationalLogger.py
+1
-1
lib/TestLoad.py
lib/TestLoad.py
+36
-0
No files found.
lib/OperationalLogger.py
View file @
8915716c
...
...
@@ -219,7 +219,7 @@ def setup(config_file=None, logger_name=None, log_filename=None, log_root_dir=No
with
open
(
config_file
,
'r'
)
as
f
:
loaded_config
=
json
.
load
(
f
)
for
key
,
val
in
loaded_config
.
items
():
if
key
in
config
and
config
[
val
]
is
None
:
if
key
in
config
and
config
[
key
]
is
None
:
logging
.
debug
(
"- setting option from file: %s --> %s"
,
key
,
val
)
config
[
key
]
=
val
# Set reasonable defaults for remaining Nones.
...
...
lib/TestLoad.py
0 → 100644
View file @
8915716c
#!/usr/bin/env python
"""Unit tests for OperationalLogging."""
import
unittest
from
nose.tools
import
raises
,
eq_
import
tempfile
import
os
import
os.path
import
logging
import
shutil
import
atexit
import
StringIO
import
OperationalLogger
as
OpLog
import
OperationalMail
as
OpMail
class
TestAll
(
unittest
.
TestCase
):
def
setUp
(
self
):
print
'
\n\n
'
self
.
temp_dir
=
tempfile
.
mkdtemp
()
self
.
log_dir
=
tempfile
.
mkdtemp
()
OpLog
.
setup
(
config_file
=
"test-config.json"
,
log_root_dir
=
self
.
log_dir
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
temp_dir
)
shutil
.
rmtree
(
self
.
log_dir
)
print
'
\n\n
'
def
test_config_file
(
self
):
logging
.
info
(
"This is an info."
)
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