Files
LangBot/pytest.ini

40 lines
674 B
INI
Raw Normal View History

feat: add comprehensive unit tests for pipeline stages (#1701) * feat: add comprehensive unit tests for pipeline stages * fix: deps install in ci * ci: use venv * ci: run run_tests.sh * fix: resolve circular import issues in pipeline tests Update all test files to use lazy imports via importlib.import_module() to avoid circular dependency errors. Fix mock_conversation fixture to properly mock list.copy() method. Changes: - Use lazy import pattern in all test files - Fix conftest.py fixture for conversation messages - Add integration test file for full import tests - Update documentation with known issues and workarounds Tests now successfully avoid circular import errors while maintaining full test coverage of pipeline stages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add comprehensive testing summary Document implementation details, challenges, solutions, and future improvements for the pipeline unit test suite. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: rewrite unit tests to test actual pipeline stage code Rewrote unit tests to properly test real stage implementations instead of mock logic: - Test actual BanSessionCheckStage with 7 test cases (100% coverage) - Test actual RateLimit stage with 3 test cases (70% coverage) - Test actual PipelineManager with 5 test cases - Use lazy imports via import_module to avoid circular dependencies - Import pipelinemgr first to ensure proper stage registration - Use Query.model_construct() to bypass Pydantic validation in tests - Remove obsolete pure unit tests that didn't test real code - All 20 tests passing with 48% overall pipeline coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: add unit tests for GroupRespondRuleCheckStage Added comprehensive unit tests for resprule stage: - Test person message skips rule check - Test group message with no matching rules (INTERRUPT) - Test group message with matching rule (CONTINUE) - Test AtBotRule removes At component correctly - Test AtBotRule when no At component present Coverage: 100% on resprule.py and atbot.py All 25 tests passing with 51% overall pipeline coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: restructure tests to tests/unit_tests/pipeline Reorganized test directory structure to support multiple test categories: - Move tests/pipeline → tests/unit_tests/pipeline - Rename .github/workflows/pipeline-tests.yml → run-tests.yml - Update run_tests.sh to run all unit tests (not just pipeline) - Update workflow to trigger on all pkg/** and tests/** changes - Coverage now tracks entire pkg/ module instead of just pipeline This structure allows for easy addition of more unit tests for other modules in the future. All 25 tests passing with 21% overall pkg coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ci: upload codecov report * ci: codecov file * ci: coverage.xml --------- Co-authored-by: Claude <noreply@anthropic.com>
2025-10-01 10:56:59 +08:00
[pytest]
# Test discovery patterns
python_files = test_*.py
python_classes = Test*
python_functions = test_*
# Test paths
testpaths = tests
# Asyncio configuration
asyncio_mode = auto
# Output options
addopts =
-v
--strict-markers
--tb=short
--disable-warnings
# Markers
markers =
asyncio: mark test as async
unit: mark test as unit test
integration: mark test as integration test
slow: mark test as slow running
# Coverage options (when using pytest-cov)
[coverage:run]
source = pkg
omit =
*/tests/*
*/test_*.py
*/__pycache__/*
*/site-packages/*
[coverage:report]
precision = 2
show_missing = True
skip_covered = False