Skip to content

Commit 37a94df

Browse files
remove unused tests
1 parent e22b878 commit 37a94df

File tree

3 files changed

+27
-269
lines changed

3 files changed

+27
-269
lines changed

tests/observability/core/test_baggage_builder.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -247,52 +247,6 @@ def test_set_pairs_accepts_dict_and_iterable(self):
247247
self.assertIsNone(baggage_contents.get(GEN_AI_CALLER_ID_KEY))
248248
self.assertIsNone(baggage_contents.get(HIRING_MANAGER_ID_KEY))
249249

250-
def test_from_turn_context_delegates_and_merges(self):
251-
"""from_turn_context should delegate to baggage_turn_context.from_turn_context and merge returned pairs."""
252-
# Import the module to monkeypatch the symbol that BaggageBuilder closed over
253-
from microsoft_agents_a365.observability.core.middleware import (
254-
baggage_builder as tempBaggageBuilder,
255-
)
256-
257-
original_fn = tempBaggageBuilder.from_turn_context
258-
259-
# Fake turn_context -> returns a mix of valid/ignored values
260-
def fake_from_turn_context(turn_ctx: any):
261-
self.assertEqual(turn_ctx, {"k": "v"}) # ensure pass-through of arg
262-
return {
263-
TENANT_ID_KEY: "tenant-ctx",
264-
GEN_AI_AGENT_ID_KEY: "agent-ctx",
265-
CORRELATION_ID_KEY: " ", # will be ignored
266-
GEN_AI_AGENT_UPN_KEY: None, # will be ignored
267-
OPERATION_SOURCE_KEY: OperationSource.SDK.value,
268-
}
269-
270-
try:
271-
tempBaggageBuilder.from_turn_context = fake_from_turn_context
272-
273-
with (
274-
BaggageBuilder()
275-
.tenant_id("tenant-pre") # will be overridden if same key is set later
276-
.from_turn_context({"k": "v"}) # merges keys from fake function
277-
.agent_auid("auid-pre") # ensure pre-existing values remain
278-
.build()
279-
):
280-
baggage_contents = baggage.get_all()
281-
# Values from turn_context
282-
self.assertEqual(baggage_contents.get(TENANT_ID_KEY), "tenant-ctx")
283-
self.assertEqual(baggage_contents.get(GEN_AI_AGENT_ID_KEY), "agent-ctx")
284-
self.assertEqual(
285-
baggage_contents.get(OPERATION_SOURCE_KEY), OperationSource.SDK.value
286-
)
287-
# Pre-existing (non-overlapping) still present
288-
self.assertEqual(baggage_contents.get(GEN_AI_AGENT_AUID_KEY), "auid-pre")
289-
# Ignored values should not be present
290-
self.assertIsNone(baggage_contents.get(CORRELATION_ID_KEY))
291-
self.assertIsNone(baggage_contents.get(GEN_AI_AGENT_UPN_KEY))
292-
finally:
293-
# Restore original
294-
tempBaggageBuilder.from_turn_context = original_fn
295-
296250
def test_source_metadata_name_method(self):
297251
"""Test deprecated source_metadata_name method - should delegate to channel_name."""
298252
# Should exist and be callable

tests/observability/core/test_turn_context_baggage.py

Lines changed: 0 additions & 211 deletions
This file was deleted.

tests/observability/hosting/token_cache_helpers/test_agent_token_cache.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,44 +44,59 @@ async def test_register_and_retrieve_token_success(
4444
expected_token = "mock-token-xyz"
4545
scopes = ["https://example.com/.default"]
4646

47-
# Setup mock
4847
mock_authorization.exchange_token.return_value = expected_token
4948

50-
# Create struct with default auth handler
5149
token_struct = AgenticTokenStruct(
5250
authorization=mock_authorization,
5351
turn_context=mock_turn_context,
5452
)
5553
assert token_struct.auth_handler_name == "AGENTIC"
5654

57-
# Register
5855
token_cache.register_observability(
5956
agent_id=agent_id,
6057
tenant_id=tenant_id,
6158
token_generator=token_struct,
6259
observability_scopes=scopes,
6360
)
6461

65-
# Retrieve token
6662
token = await token_cache.get_observability_token(agent_id, tenant_id)
67-
6863
assert token == expected_token
69-
mock_authorization.exchange_token.assert_called_once_with(
70-
context=mock_turn_context,
71-
scopes=scopes,
72-
auth_handler_id="AGENTIC",
73-
)
7464

7565

7666
@pytest.mark.parametrize(
7767
"agent_id,tenant_id,token_generator,error_type,error_match",
7868
[
7969
("", "tenant-456", "valid", ValueError, "agent_id cannot be None or whitespace"),
80-
("agent-123", None, "valid", ValueError, "tenant_id cannot be None or whitespace"),
8170
("agent-123", "tenant-456", None, TypeError, "token_generator cannot be None"),
8271
],
8372
)
84-
@pytest.mark.asyncio
73+
def test_register_observability_validation(
74+
token_cache,
75+
mock_authorization,
76+
mock_turn_context,
77+
agent_id,
78+
tenant_id,
79+
token_generator,
80+
error_type,
81+
error_match,
82+
):
83+
"""Test that registration validates inputs and raises appropriate errors."""
84+
struct = None
85+
if token_generator == "valid":
86+
struct = AgenticTokenStruct(
87+
authorization=mock_authorization,
88+
turn_context=mock_turn_context,
89+
)
90+
91+
with pytest.raises(error_type, match=error_match):
92+
token_cache.register_observability(
93+
agent_id=agent_id,
94+
tenant_id=tenant_id,
95+
token_generator=struct,
96+
observability_scopes=["scope"],
97+
)
98+
99+
85100
def test_thread_safety(token_cache, mock_authorization, mock_turn_context):
86101
"""Test that cache is thread-safe with concurrent registrations."""
87102
import threading

0 commit comments

Comments
 (0)