mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
5c992eb7ae
* move all tests under tests and initial work on int tests * added updated tests setup and merge tests * without failing step * fixed upload * updated file names for coverage * reenable surface tests * removed package matrix * simplified variables * correct path * removed mistake * fix mistake in path * fix path * windows specific env set * updated merge tests * slight update in marker * added run integration tests settings * updated setup, moved foundry int tests and updated merge test
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
|
|
import pytest
|
|
|
|
from agent_framework import get_logger
|
|
from agent_framework.exceptions import AgentFrameworkException
|
|
|
|
|
|
def test_get_logger():
|
|
"""Test that the logger is created with the correct name."""
|
|
logger = get_logger()
|
|
assert logger.name == "agent_framework"
|
|
|
|
|
|
def test_get_logger_custom_name():
|
|
"""Test that the logger can be created with a custom name."""
|
|
custom_name = "agent_framework.custom"
|
|
logger = get_logger(custom_name)
|
|
assert logger.name == custom_name
|
|
|
|
|
|
def test_get_logger_invalid_name():
|
|
"""Test that an exception is raised for an invalid logger name."""
|
|
with pytest.raises(AgentFrameworkException, match="Logger name must start with 'agent_framework'."):
|
|
get_logger("invalid_name")
|
|
|
|
|
|
def test_log(caplog):
|
|
"""Test that the logger can log messages and adheres to the expected format."""
|
|
logger = get_logger()
|
|
with caplog.at_level("DEBUG"):
|
|
logger.debug("This is a debug message")
|
|
assert len(caplog.records) == 1
|
|
record = caplog.records[0]
|
|
assert record.levelname == "DEBUG"
|
|
assert record.message == "This is a debug message"
|
|
assert record.name == "agent_framework"
|
|
assert record.pathname.endswith("test_logging.py")
|