Files
validations-libs/validations_libs/tests/test_logger.py
Oliver Walsh feba372e2d Drop lack of syslog warning to debug level logging
The current warning spams openstackclient output with multiple log messages
(one for every call to getLogger in the entrypoints that are loaded). Drop
the message to debug level.

Resolves: rhbz#2227201
Change-Id: Ib32146020f5869c88cc8becf41c9245a0c4863c3
2023-08-01 14:22:15 +00:00

45 lines
1.4 KiB
Python

# Copyright 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
import logging
from validations_libs import logger
class TestLogger(TestCase):
def setUp(self) -> None:
super().setUp()
@mock.patch('os.path.exists', reutrn_value=True)
def test_logger_init(self, mock_exists):
new_logger = logger.getLogger("fooo")
mock_exists.assert_called_once_with('/dev/log')
self.assertEqual(logging.Logger, type(new_logger))
@mock.patch('logging.Logger.debug')
@mock.patch('os.path.exists', return_value=False)
def test_logger_init_no_journal(self, mock_exists, mock_debug):
new_logger = logger.getLogger("fooo")
mock_exists.assert_called_once_with('/dev/log')
mock_debug.assert_called_once()
self.assertEqual(logging.Logger, type(new_logger))