mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
0521f5bed8
* [BREAKING] Rename ChatAgent -> Agent, ChatMessage -> Message, ChatClientProtocol -> SupportsChatGetResponse Simplify the public API by removing redundant 'Chat' prefix from core types: - ChatAgent -> Agent - RawChatAgent -> RawAgent - ChatMessage -> Message - ChatClientProtocol -> SupportsChatGetResponse Also renamed internal WorkflowMessage (was Message in _runner_context) to avoid collision. No backward compatibility aliases - this is a clean breaking change. * [BREAKING] Rename Agent chat_client parameter to client * Fix rebase issues: WorkflowMessage references and broken markdown links * Fix formatting and lint issues from code quality checks * Fix import ordering in workflow sample files * fixed rebase * Fix test failures: use WorkflowMessage and A2AMessage after ChatMessage→Message rename - Replace Message(data=..., source_id=...) with WorkflowMessage(...) in workflow tests - Fix isinstance check in A2A agent to use A2AMessage instead of Message - Fix import in test_workflow_observability.py (Message→WorkflowMessage) * Fix lint, fmt, and sample errors after ChatMessage→Message rename - Auto-fix 70+ ruff lint issues across samples (ChatMessage→Message refs) - Fix HostedVectorStoreContent→Content.from_hosted_vector_store in file search sample - Fix _normalize_messages→normalize_messages in custom agent sample - Fix context.terminate→raise MiddlewareTermination in middleware samples - Fix with_update_hook→with_transform_hook in override middleware sample - Add TOptions_co import back to custom_chat_client sample - Add noqa for FastAPI File() default in chatkit sample - Fix B023 loop variable capture in weather agent sample * fix: update Agent constructor calls from chat_client to client in declaration-only tool tests * fix: add register_cleanup to devui lazy-loading proxy and type stub * fixed tests and updated new pieces * fix agui typevar * fix merge errors * fix merge conflicts * fiux merge * Remove unused links --------- Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
83 lines
3.2 KiB
Python
83 lines
3.2 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
"""Tests for Purview settings."""
|
|
|
|
import pytest
|
|
|
|
from agent_framework_purview import PurviewAppLocation, PurviewLocationType, PurviewSettings
|
|
|
|
|
|
class TestPurviewSettings:
|
|
"""Test PurviewSettings configuration."""
|
|
|
|
def test_settings_defaults(self) -> None:
|
|
"""Test PurviewSettings with default values."""
|
|
settings = PurviewSettings(app_name="Test App")
|
|
|
|
assert settings.app_name == "Test App"
|
|
assert settings.graph_base_uri == "https://graph.microsoft.com/v1.0/"
|
|
assert settings.tenant_id is None
|
|
assert settings.purview_app_location is None
|
|
|
|
def test_settings_with_custom_values(self) -> None:
|
|
"""Test PurviewSettings with custom values."""
|
|
app_location = PurviewAppLocation(location_type=PurviewLocationType.APPLICATION, location_value="app-123")
|
|
|
|
settings = PurviewSettings(
|
|
app_name="Test App",
|
|
graph_base_uri="https://graph.microsoft-ppe.com",
|
|
tenant_id="test-tenant-id",
|
|
purview_app_location=app_location,
|
|
)
|
|
|
|
assert settings.graph_base_uri == "https://graph.microsoft-ppe.com"
|
|
assert settings.tenant_id == "test-tenant-id"
|
|
assert settings.purview_app_location.location_value == "app-123"
|
|
|
|
@pytest.mark.parametrize(
|
|
"graph_uri,expected_scope",
|
|
[
|
|
("https://graph.microsoft.com/v1.0/", "https://graph.microsoft.com/.default"),
|
|
("https://graph.microsoft-ppe.com/v1.0/", "https://graph.microsoft-ppe.com/.default"),
|
|
],
|
|
)
|
|
def test_get_scopes(self, graph_uri: str, expected_scope: str) -> None:
|
|
"""Test get_scopes returns correct scope for different URIs."""
|
|
settings = PurviewSettings(app_name="Test App", graph_base_uri=graph_uri)
|
|
scopes = settings.get_scopes()
|
|
|
|
assert len(scopes) == 1
|
|
assert expected_scope in scopes
|
|
|
|
|
|
class TestPurviewAppLocation:
|
|
"""Test PurviewAppLocation configuration."""
|
|
|
|
@pytest.mark.parametrize(
|
|
"location_type,location_value,expected_odata_type",
|
|
[
|
|
(PurviewLocationType.APPLICATION, "app-123", "microsoft.graph.policyLocationApplication"),
|
|
(PurviewLocationType.URI, "https://example.com", "microsoft.graph.policyLocationUrl"),
|
|
(PurviewLocationType.DOMAIN, "example.com", "microsoft.graph.policyLocationDomain"),
|
|
],
|
|
)
|
|
def test_get_policy_location(
|
|
self, location_type: PurviewLocationType, location_value: str, expected_odata_type: str
|
|
) -> None:
|
|
"""Test get_policy_location returns correct structure for all location types."""
|
|
location = PurviewAppLocation(location_type=location_type, location_value=location_value)
|
|
policy_location = location.get_policy_location()
|
|
|
|
assert policy_location["@odata.type"] == expected_odata_type
|
|
assert policy_location["value"] == location_value
|
|
|
|
|
|
class TestPurviewLocationType:
|
|
"""Test PurviewLocationType enum."""
|
|
|
|
def test_location_type_values(self) -> None:
|
|
"""Test PurviewLocationType enum has expected values."""
|
|
assert PurviewLocationType.APPLICATION == "application"
|
|
assert PurviewLocationType.URI == "uri"
|
|
assert PurviewLocationType.DOMAIN == "domain"
|