Files
microsoft--agent-framework/python/packages/azurefunctions/tests/test_errors.py
T
wehub-resource-sync db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:25 +08:00

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