mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
cd1e3110aa
* Initial plan * Initial analysis: azurefunctions package at 80% coverage, need 85% Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Add comprehensive unit tests to achieve 86% coverage for azurefunctions package Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Add comprehensive coverage report documentation for azurefunctions package Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Fix linting errors: combine nested with statements in test_entities.py Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Remove COVERAGE_REPORT.md and coverage.json files as requested Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> * Address PR review feedback: fix unused variables, remove line numbers from docstrings, improve test clarity Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: larohra <41490930+larohra@users.noreply.github.com> Co-authored-by: Laveesh Rohra <larohra@microsoft.com> Co-authored-by: Tao Chen <taochen@microsoft.com>
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
"""Unit tests for custom exception types."""
|
|
|
|
import pytest
|
|
|
|
from agent_framework_azurefunctions._errors import IncomingRequestError
|
|
|
|
|
|
class TestIncomingRequestError:
|
|
"""Test suite for IncomingRequestError exception."""
|
|
|
|
def test_incoming_request_error_default_status_code(self) -> None:
|
|
"""Test that IncomingRequestError has a default status code of 400."""
|
|
error = IncomingRequestError("Invalid request")
|
|
|
|
assert str(error) == "Invalid request"
|
|
assert error.status_code == 400
|
|
|
|
def test_incoming_request_error_custom_status_code(self) -> None:
|
|
"""Test that IncomingRequestError can have a custom status code."""
|
|
error = IncomingRequestError("Unauthorized", status_code=401)
|
|
|
|
assert str(error) == "Unauthorized"
|
|
assert error.status_code == 401
|
|
|
|
def test_incoming_request_error_is_value_error(self) -> None:
|
|
"""Test that IncomingRequestError inherits from ValueError."""
|
|
error = IncomingRequestError("Test error")
|
|
|
|
assert isinstance(error, ValueError)
|
|
|
|
def test_incoming_request_error_can_be_raised_and_caught(self) -> None:
|
|
"""Test that IncomingRequestError can be raised and caught."""
|
|
with pytest.raises(IncomingRequestError) as exc_info:
|
|
raise IncomingRequestError("Bad request", status_code=400)
|
|
|
|
assert exc_info.value.status_code == 400
|