Skip to content

Commit

Permalink
add simple test for log_setting.LogTeeHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Apr 2, 2024
1 parent 22ba65e commit 4013bcb
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_log_setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2022 TIER IV, INC. All rights reserved.
#
# 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.


from __future__ import annotations

import logging

from otaclient.app import log_setting

MODULE = log_setting.__name__
logger = logging.getLogger(__name__)


def test_server_logger():
test_log_msg = "emit one logging entry"

# ------ setup test ------ #
_handler = log_setting._LogTeeHandler()
logger.addHandler(_handler)

# ------ execution ------ #
logger.info(test_log_msg)

# ------ clenaup ------ #
logger.removeHandler(_handler)

# ------ check result ------ #
_queue = _handler._queue
_log = _queue.get_nowait()
assert _log == test_log_msg

0 comments on commit 4013bcb

Please sign in to comment.