1# Copyright 2017 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from __future__ import absolute_import 6from __future__ import division 7from __future__ import print_function 8 9import argparse 10import unittest 11 12import mock 13 14from lucifer import loglib 15 16 17class LogLibTestCase(unittest.TestCase): 18 """Module unit tests.""" 19 20 def test_configure_logging(self): 21 """Test that dict can be evaluated.""" 22 with mock.patch('logging.config.dictConfig', 23 autospec=True) as dictConfig: 24 loglib.configure_logging(name='unittest') 25 dictConfig.assert_called_once_with(mock.ANY) 26 27 def test_parse_and_config_defaults(self): 28 """Test default args satisfy configure_logging_with_args().""" 29 parser = argparse.ArgumentParser(prog='unittest') 30 loglib.add_logging_options(parser) 31 args = parser.parse_args([]) 32 with mock.patch.object(loglib, 'configure_logging', 33 autospec=True) as configure: 34 loglib.configure_logging_with_args(parser, args) 35 configure.assert_called_once_with(name='unittest') 36