add tests for onedns base exception

master
Justin Riley 2016-08-19 12:28:10 -04:00
parent a97e9f687c
commit 8bad8b47d4
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
from onedns import exception
from testfixtures import LogCapture
def test_onedns_exception():
test_msg = "test message"
e = exception.OneDnsException("test message")
assert e.msg == test_msg
assert e.args == (test_msg,)
assert str(e) == test_msg
assert e.explain() == 'OneDnsException: {}'.format(test_msg)
with LogCapture() as log_capture:
e.log()
e.log(warn=True)
log_capture.check(
('onedns', 'ERROR', e.explain()),
('onedns', 'WARNING', e.explain()),
)