mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Add tests to Purview Package (#3513)
* Add tests to increase code coverage * Add tests to increase code coverage
This commit is contained in:
committed by
GitHub
Unverified
parent
493891620d
commit
2f7250fe0f
@@ -119,6 +119,25 @@ class TestInMemoryCacheProvider:
|
||||
|
||||
assert result == obj
|
||||
|
||||
async def test_estimate_size_conservative_fallback_when_all_size_methods_fail(self, monkeypatch) -> None:
|
||||
"""Test that the cache returns a conservative size estimate when all strategies fail."""
|
||||
cache = InMemoryCacheProvider()
|
||||
|
||||
class BadString:
|
||||
def __str__(self) -> str:
|
||||
raise RuntimeError("boom")
|
||||
|
||||
def raise_getsizeof(_: object) -> int:
|
||||
raise RuntimeError("no sizeof")
|
||||
|
||||
monkeypatch.setattr("agent_framework_purview._cache.sys.getsizeof", raise_getsizeof)
|
||||
|
||||
# Arrange/Act
|
||||
size = cache._estimate_size(BadString())
|
||||
|
||||
# Assert
|
||||
assert size == 1024
|
||||
|
||||
async def test_cache_multiple_updates(self) -> None:
|
||||
"""Test that updating a key multiple times maintains correct size tracking."""
|
||||
cache = InMemoryCacheProvider(max_size_bytes=1000)
|
||||
|
||||
Reference in New Issue
Block a user