mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-20 11:47:00 +00:00
- Implement llama version command with table and JSON output formats - Add build-time git information capture via scripts/generate_build_info.py - Include comprehensive unit test suite (test_version.py, test_version_simple.py, test_version_integration.py) - Add build system integration with custom setup.py command - Update .gitignore to exclude generated build info file Features: - Display Llama Stack and client versions - Show Python version and build information (git commit, date, branch, tag) - Optional component/provider listing organized by API - Support for both table and JSON output formats - Build-time capture of git metadata for version tracking Testing: - 8 unit tests covering all functionality - Integration tests for CLI execution - Simple dependency-free validation tests - Documentation for test suite and build process Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com> |
||
---|---|---|
.. | ||
README.md | ||
test_stack_config.py | ||
test_version.py | ||
test_version_integration.py | ||
test_version_simple.py |
CLI Unit Tests
This directory contains unit tests for the Llama Stack CLI commands.
Test Files
test_version.py
Comprehensive unit tests for the llama version
command using pytest and mocking. These tests cover:
- Package version retrieval
- Build information handling
- Component information retrieval
- JSON and table output formats
- Error handling scenarios
- Component type detection
Requirements: pytest, unittest.mock
Run with: pytest tests/unit/cli/test_version.py -v
test_version_simple.py
Simple unit tests that can run without external dependencies. These tests verify:
- File structure and existence
- Code structure and imports
- Logic validation
- Configuration correctness
Requirements: None (uses only standard library)
Run with: python tests/unit/cli/test_version_simple.py
test_version_integration.py
Integration tests that test the actual CLI command execution. These tests:
- Execute the actual CLI commands
- Verify command-line interface
- Test real output formats
- Validate build script execution
Requirements: Full Llama Stack environment
Run with: python tests/unit/cli/test_version_integration.py
test_stack_config.py
Tests for stack configuration parsing and upgrading.
Running Tests
Run All CLI Tests
# With pytest (if available)
pytest tests/unit/cli/ -v
# Simple tests only (no dependencies)
python tests/unit/cli/test_version_simple.py
Run Specific Tests
# Run version command tests
python tests/unit/cli/test_version_simple.py
# Run integration tests (requires full environment)
python tests/unit/cli/test_version_integration.py
Test Coverage
The version command tests cover:
- ✅ Package version detection
- ✅ Build information retrieval
- ✅ Component discovery and listing
- ✅ JSON output format
- ✅ Table output format
- ✅ Error handling
- ✅ CLI integration
- ✅ Build script functionality
- ✅ File structure validation
Adding New Tests
When adding new CLI commands or functionality:
- Create unit tests following the pattern in
test_version.py
- Add simple validation tests in a
test_<command>_simple.py
file - Consider integration tests for end-to-end validation
- Update this README with the new test information
Notes
- Simple tests are preferred for CI/CD as they have no external dependencies
- Integration tests are useful for local development and full validation
- Mock-based tests provide comprehensive coverage of edge cases