Refactoring storage and unifying unit tests#66
Merged
Conversation
axelsrz
approved these changes
Jul 17, 2025
kylerohnmsft
added a commit
that referenced
this pull request
Jul 21, 2025
Refactoring storage and unifying unit tests (#66)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant refactoring and enhancements to the storage library, focusing on improved modularity, error handling, and test coverage. Key changes include the introduction of a new
BlobStorageConfigclass for configuration, the creation of a base class for asynchronous storage (AsyncStorageBase), enhanced error handling utilities, and updates to memory storage functionality. Additionally, comprehensive tests have been added to ensure robustness.Refactoring and Modularization
BlobStorageConfigto encapsulate configuration settings forBlobStorage, replacing the previousBlobStorageSettingsclass. ([[1]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-da130280c6bf0eaf3149def4f772f961350aa71306930613070afe272f830909L1-R4),[[2]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-2a6302200acf3a2a75a861131b14e54bf9061b578120040f021d7bba81c34790R1-R28),[[3]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-a224ef42e2a15b06a12f8ef2842f38c73ac8ec2751f03754c90e686085f661ffL1-R97))BlobStorageto inherit from the newAsyncStorageBaseclass, which provides shared logic for asynchronous storage operations likeread,write, anddelete. ([[1]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-e2b9bfabe0f61421ebdb756837c46cc904905df770dd1dd3a5831d10a79a6d35R16-R98),[[2]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-a224ef42e2a15b06a12f8ef2842f38c73ac8ec2751f03754c90e686085f661ffL1-R97))BlobStorage, such as the connection string conversion logic, to streamline the implementation. ([libraries/Storage/microsoft-agents-blob/microsoft/agents/blob/blob_storage.pyL1-R97](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-a224ef42e2a15b06a12f8ef2842f38c73ac8ec2751f03754c90e686085f661ffL1-R97))Error Handling Enhancements
ignore_errorandis_status_code_errorutilities to handle specific exceptions gracefully, such as ignoring 404 errors during blob operations. ([libraries/Storage/microsoft-agents-storage/microsoft/agents/storage/error_handling.pyR1-R31](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-9ee3c025fd3a28944e6cd26ab7b1fb4b88f94f0de4f18bed0007e1277d29c4a7R1-R31))BlobStoragemethods (_read_item,_write_item,_delete_item) to use these error-handling utilities, ensuring better resilience. ([libraries/Storage/microsoft-agents-blob/microsoft/agents/blob/blob_storage.pyL1-R97](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-a224ef42e2a15b06a12f8ef2842f38c73ac8ec2751f03754c90e686085f661ffL1-R97))Memory Storage Improvements
MemoryStorageto prevent empty keys and ensure that required parameters are provided forread,write, anddeleteoperations. ([[1]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-b33ecf4806c2605510d6635be8a5203db2c2c9b307ef367c5d363fed4f47681aR20-R30),[[2]](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-b33ecf4806c2605510d6635be8a5203db2c2c9b307ef367c5d363fed4f47681aR51-R62))readmethod to raise errors for invalid inputs and handle missing keys more robustly. ([libraries/Storage/microsoft-agents-storage/microsoft/agents/storage/memory_storage.pyR20-R30](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-b33ecf4806c2605510d6635be8a5203db2c2c9b307ef367c5d363fed4f47681aR20-R30))Test Coverage
ignore_error,is_status_code_error) to verify their behavior under various scenarios. ([libraries/Storage/microsoft-agents-storage/tests/test_error_handling.pyR1-R58](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-14bbb4f6bae2d8e6951f33c84b305e2c3539e4ced0bb5e05175bbec5a88b1346R1-R58))MemoryStorageusing a mock-based approach to validate CRUD operations. ([libraries/Storage/microsoft-agents-storage/tests/test_memory_storage.pyR1-R22](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-60ba7611f46e6f4fee8ba40fbae6b1a63ad9df734e5e19abe69b0f0c1ef74a19R1-R22))[libraries/Storage/microsoft-agents-storage/tests/test_utils.pyR1-R93](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-7911a2ba7e6cf1ed63e718a9d6f6236071e34e763a7f821ae272c4b7eac9bf5bR1-R93))Integration Updates
test_memory_storage_integrationfunction to use the newtarget_clsparameter when reading from memory storage, aligning with the refactored interface. ([libraries/Builder/microsoft-agents-builder/tests/test_agent_state.pyL494-R494](https://github.com/microsoft/Agents-for-python/pull/66/files#diff-b47c6aca37e78ad0b03015b4d66f4f4e93e097b9a3c8cffa66fd0a9299b9163dL494-R494))