llama-stack-mirror/tests/unit/distribution
Matthew Farrellee b69bafba30
fix(library_client): improve initialization error handling and prevent AttributeError (#2944)
# What does this PR do?

- Initialize route_impls to None in constructor to prevent
AttributeError
- Consolidate initialization checks to single point in request() method
- Improve error message to be more helpful ("Please call initialize()
first")
- Add comprehensive test suite to prevent regressions

The library client now has better error handling when users forget to
call initialize(), showing a clear ValueError instead of confusing
AttributeError. All initialization validation is now centralized in the
request() method, with internal methods (_call_non_streaming,
_call_streaming, _convert_body) relying on this single check for
cleaner, more maintainable code.

closes #2943 

## Test Plan

`./scripts/unit-tests.sh`
2025-07-30 11:58:47 -04:00
..
routers feat(starter)!: simplify starter distro; litellm model registry changes (#2916) 2025-07-25 15:02:04 -07:00
routing_tables chore: Adding Access Control for OpenAI Vector Stores methods (#2772) 2025-07-21 16:22:44 -04:00
test_build_path.py feat: include run.yaml in the container image (#2005) 2025-04-24 11:29:53 +02:00
test_context.py chore: default to pytest asyncio-mode=auto (#2730) 2025-07-11 13:00:24 -07:00
test_distribution.py fix: Fix unit tests CI and failing tests (#2928) 2025-07-28 10:07:26 -07:00
test_inference_recordings.py feat(tests): introduce inference record/replay to increase test reliability (#2941) 2025-07-29 12:41:31 -07:00
test_library_client_initialization.py fix(library_client): improve initialization error handling and prevent AttributeError (#2944) 2025-07-30 11:58:47 -04:00