Exemple #1
0
    def test_with_no_predefined_vars(self, fake_log, triggers):
        env.init()

        fake_log.assert_called_with(level=None, handlers=unittest.mock.ANY, format='%(levelname)s:%(name)s:%(asctime)s %(message)s')
        pos_args, expected_args = fake_log.call_args
        expected_handlers = expected_args['handlers']
        self.assertEqual(1, len(expected_handlers))
        self.assertIsInstance(expected_handlers[0], logging.StreamHandler)
Exemple #2
0
 def test_sets_logfile_with_env_vars(self, fake_makedirs, abspath, fake_log, triggers):
     with patch.object(logging.handlers, 'RotatingFileHandler', spec=logging.handlers.RotatingFileHandler) as fake_file_handler:
         env.init()
         fake_makedirs.assert_called_with('/abs/path/foo/bar/testhost/testlog', exist_ok=True)
         fake_file_handler.assert_called_with('foo/bar/testhost/testlog/app.log', maxBytes=5*1024*1024, backupCount=1)
     
     pos_args, expected_args = fake_log.call_args
     expected_handlers = expected_args['handlers']
     self.assertEqual(2, len(expected_handlers))
     self.assertIsInstance(expected_handlers[1], logging.handlers.RotatingFileHandler)
Exemple #3
0
    def test_sets_loglevel_if_specified(self, fake_log, triggers):
        env.init()

        fake_log.assert_called_with(level=logging.INFO, handlers=unittest.mock.ANY, format='%(levelname)s:%(name)s:%(asctime)s %(message)s')
Exemple #4
0
    def test(self, fake_log, triggers):
        env.init()

        triggers.init.assert_called_with()