chore: import upstream snapshot with attribution
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
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
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
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user