Skip to content

test: expand coverage for core config, utils, and batch parser#218

Open
Jah-yee wants to merge 2 commits intoHKUDS:mainfrom
Jah-yee:test-core-modules
Open

test: expand coverage for core config, utils, and batch parser#218
Jah-yee wants to merge 2 commits intoHKUDS:mainfrom
Jah-yee:test-core-modules

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 2, 2026

Summary

This PR adds a new test module to increase coverage for several core components that previously had little or no automated testing, including configuration, utility helpers, status enums, and the batch parser.

Motivation

Most existing tests focus on parser wiring and paddleocr integration. Core pieces such as configuration, content separation, image utilities, and the batch parser are either untested or only indirectly exercised, which makes refactoring risky. These tests aim to capture current behavior so future changes are safer.

Changes

  • tests/test_core_modules.py
    • Tests for: base.DocStatus, config.RAGAnythingConfig, utils.separate_content, utils.encode_image_to_base64, utils.validate_image_file, utils.get_processor_for_type, utils.get_processor_supports, batch_parser.BatchProcessingResult, and batch_parser.BatchParser initialization/basic behavior.
    • Focus on happy-path behavior, key edge cases, validation, and error handling.

Testing

  • Ran pytest locally including tests/test_core_modules.py; all tests passed.
  • Confirmed the existing test suite continues to pass unchanged.

Thanks for your work on RAG-Anything—if you prefer a different organization for these tests (e.g. split by module), I’m happy to rearrange them.

@LarFii
Copy link
Collaborator

LarFii commented Mar 4, 2026

  1. Blocking lint issue (F401 unused imports) in tests/test_core_modules.py
    The new test file imports symbols that are not used:
  • import tempfile (tests/test_core_modules.py:10)
  • from unittest.mock import MagicMock, patch (tests/test_core_modules.py:12)
    Since this repo runs ruff via pre-commit in CI, these F401 findings will fail checks.
  1. test_default_values is environment-sensitive and may be flaky
    RAGAnythingConfig defaults are resolved through environment variables (get_env_value(...)), but test_default_values assumes fixed defaults with no env overrides. If CI/local env sets variables like PARSE_METHOD, PARSER, or MAX_CONCURRENT_FILES, the test can fail despite correct code behavior.
    Recommendation: explicitly isolate/clear related env vars in this test (e.g., with monkeypatch.delenv) or refactor the test to validate override behavior explicitly.

@Jah-yee
Copy link
Author

Jah-yee commented Mar 4, 2026

Thanks for reviewing the test coverage PR and for pointing out these two issues.

I removed the unused imports (tempfile, MagicMock, patch) from tests/test_core_modules.py, so Ruff no longer reports F401 warnings. For test_default_values, I now explicitly clear the relevant env vars via monkeypatch.delenv(...) (e.g. PARSER, PARSE_METHOD, MAX_CONCURRENT_FILES and related flags) before instantiating RAGAnythingConfig, so the test is deterministic and not sensitive to CI or local shell env.

If you think it would be useful, I can also add a separate test that asserts env overrides are respected to complement the default-values test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants