diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_cfg.py | 56 | ||||
-rw-r--r-- | tests/unit/test_log.py | 61 |
2 files changed, 56 insertions, 61 deletions
diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index b2c14ec..8eaaf67 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -1573,62 +1573,6 @@ class OptDumpingTestCase(BaseTestCase): ]) -class CommonOptsTestCase(BaseTestCase): - - def setUp(self): - super(CommonOptsTestCase, self).setUp() - self.conf = CommonConfigOpts() - - def test_print_help(self): - f = StringIO.StringIO() - self.conf([]) - self.conf.print_help(file=f) - self.assertTrue('debug' in f.getvalue()) - self.assertTrue('verbose' in f.getvalue()) - self.assertTrue('log-config' in f.getvalue()) - self.assertTrue('log-format' in f.getvalue()) - - def test_debug_verbose(self): - self.conf(['--debug', '--verbose']) - - self.assertEquals(self.conf.debug, True) - self.assertEquals(self.conf.verbose, True) - - def test_logging_opts(self): - self.conf([]) - - self.assertTrue(self.conf.log_config is None) - self.assertTrue(self.conf.log_file is None) - self.assertTrue(self.conf.log_dir is None) - - self.assertEquals(self.conf.log_format, - CommonConfigOpts.DEFAULT_LOG_FORMAT) - self.assertEquals(self.conf.log_date_format, - CommonConfigOpts.DEFAULT_LOG_DATE_FORMAT) - - self.assertEquals(self.conf.use_syslog, False) - - def test_log_file(self): - log_file = '/some/path/foo-bar.log' - self.conf(['--log-file', log_file]) - self.assertEquals(self.conf.log_file, log_file) - - def test_logfile_deprecated(self): - logfile = '/some/other/path/foo-bar.log' - self.conf(['--logfile', logfile]) - self.assertEquals(self.conf.log_file, logfile) - - def test_log_dir(self): - log_dir = '/some/path/' - self.conf(['--log-dir', log_dir]) - self.assertEquals(self.conf.log_dir, log_dir) - - def test_logdir_deprecated(self): - logdir = '/some/other/path/' - self.conf(['--logdir', logdir]) - self.assertEquals(self.conf.log_dir, logdir) - - class ConfigParserTestCase(unittest.TestCase): def test_no_section(self): with tempfile.NamedTemporaryFile() as tmpfile: diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index a2ba31a..451fb4f 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -1,6 +1,7 @@ import cStringIO import exceptions import logging +import StringIO import subprocess import sys import textwrap @@ -74,22 +75,22 @@ class LoggerTestCase(test_utils.BaseTestCase): class LogHandlerTestCase(test_utils.BaseTestCase): def test_log_path_logdir(self): - self.config(logdir='/some/path', logfile=None) + self.config(log_dir='/some/path', log_file=None) self.assertEquals(log._get_log_file_path(binary='foo-bar'), '/some/path/foo-bar.log') def test_log_path_logfile(self): - self.config(logfile='/some/path/foo-bar.log') + self.config(log_file='/some/path/foo-bar.log') self.assertEquals(log._get_log_file_path(binary='foo-bar'), '/some/path/foo-bar.log') def test_log_path_none(self): - self.config(logdir=None, logfile=None) + self.config(log_dir=None, log_file=None) self.assertTrue(log._get_log_file_path(binary='foo-bar') is None) def test_log_path_logfile_overrides_logdir(self): - self.config(logdir='/some/other/path', - logfile='/some/path/foo-bar.log') + self.config(log_dir='/some/other/path', + log_file='/some/path/foo-bar.log') self.assertEquals(log._get_log_file_path(binary='foo-bar'), '/some/path/foo-bar.log') @@ -328,3 +329,53 @@ class SetDefaultsTestCase(test_utils.BaseTestCase): log.set_defaults(logging_context_format_string=my_default) self.conf([]) self.assertEquals(self.conf.logging_context_format_string, my_default) + + +class LogConfigOptsTestCase(test_utils.BaseTestCase): + + def test_print_help(self): + f = StringIO.StringIO() + CONF([]) + CONF.print_help(file=f) + self.assertTrue('debug' in f.getvalue()) + self.assertTrue('verbose' in f.getvalue()) + self.assertTrue('log-config' in f.getvalue()) + self.assertTrue('log-format' in f.getvalue()) + + def test_debug_verbose(self): + CONF(['--debug', '--verbose']) + + self.assertEquals(CONF.debug, True) + self.assertEquals(CONF.verbose, True) + + def test_logging_opts(self): + CONF([]) + + self.assertTrue(CONF.log_config is None) + self.assertTrue(CONF.log_file is None) + self.assertTrue(CONF.log_dir is None) + + self.assertEquals(CONF.log_format, log._DEFAULT_LOG_FORMAT) + self.assertEquals(CONF.log_date_format, log._DEFAULT_LOG_DATE_FORMAT) + + self.assertEquals(CONF.use_syslog, False) + + def test_log_file(self): + log_file = '/some/path/foo-bar.log' + CONF(['--log-file', log_file]) + self.assertEquals(CONF.log_file, log_file) + + def test_logfile_deprecated(self): + logfile = '/some/other/path/foo-bar.log' + CONF(['--logfile', logfile]) + self.assertEquals(CONF.log_file, logfile) + + def test_log_dir(self): + log_dir = '/some/path/' + CONF(['--log-dir', log_dir]) + self.assertEquals(CONF.log_dir, log_dir) + + def test_logdir_deprecated(self): + logdir = '/some/other/path/' + CONF(['--logdir', logdir]) + self.assertEquals(CONF.log_dir, logdir) |