Skip to content

test: Add unit tests and update workflow configuration#543

Merged
Prajwal-Microsoft merged 17 commits intodevfrom
psl-unit-test-cps-v2
Apr 20, 2026
Merged

test: Add unit tests and update workflow configuration#543
Prajwal-Microsoft merged 17 commits intodevfrom
psl-unit-test-cps-v2

Conversation

@Prachig-Microsoft
Copy link
Copy Markdown
Contributor

Purpose

This pull request significantly enhances the testing infrastructure and automation for the ContentProcessor project. It introduces comprehensive unit tests for core modules, configures coverage reporting, and expands the GitHub Actions workflow to run separate test jobs for backend, API, and workflow components. It also updates the Python version used in CI and improves test file structure and coverage configuration.

Does this introduce a breaking change?

  • Yes
  • No

CI/CD Workflow Improvements:

  • Added new branches to trigger CI, including psl-unit-test-cps-v2.
  • Upgraded the CI Python version from 3.11 to 3.12 for all jobs.
  • Refined backend test file discovery and test execution commands for better accuracy and coverage reporting. [1] [2]
  • Introduced dedicated CI jobs for API and workflow tests, each with environment setup, dependency installation, coverage enforcement, and conditional skipping if no tests are found.

Testing and Coverage Enhancements:

  • Added a .coveragerc file in src/tests/ContentProcessor to focus coverage on core business logic and exclude integration, test, and external dependency files.
  • Included a README.md in src/tests/ContentProcessor documenting the test structure, coverage expectations, and usage instructions.

New Unit Tests for Core Modules:

  • Added unit tests for application configuration logic in application/test_application_configuration.py.
  • Added tests for LLM service configuration and validation in application/test_service_config.py.
  • Added tests for Azure content understanding model classes in azure_helper/test_content_understanding_model.py.
  • Added tests for Cosmos DB Mongo API helper, leveraging mongomock for isolated CRUD operation testing, in azure_helper/test_cosmos_mongo.py.

What to Check

Verify that the following are valid

  • ...

Other Information

- Merged latest dev branch into psl-unit-test-cps-v2
- Fixed ContentProcessorAPI test for credential_scopes parameter
- Fixed ContentProcessorWorkflow logging and app configuration tests
- Added comprehensive tests for content_process_models.py (100% coverage)
- Added comprehensive tests for content_process_service.py (98.81% coverage)
- All modules now exceed 80% coverage threshold:
  * ContentProcessor: 86.68%
  * ContentProcessorAPI: 84.86%
  * ContentProcessorWorkflow: 92.13%
…flow

- Added services/ directory to pytest command in test.yml
- This ensures the new test_content_process_models.py and test_content_process_service.py are run in CI
- Fixes coverage from 70.68% to 92.13%
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the automated test suite and CI execution for the ContentProcessor solution by adding new unit tests (Backend/ContentProcessor, API, Workflow) along with per-component coverage configuration, and updating the GitHub Actions test workflow to run separate jobs.

Changes:

  • Added substantial new unit test coverage across ContentProcessor, ContentProcessorAPI, and ContentProcessorWorkflow.
  • Introduced per-component pytest.ini, conftest.py, and .coveragerc files plus test README docs.
  • Updated .github/workflows/test.yml to Python 3.12 and split CI into backend/api/workflow test jobs with coverage gates.

Reviewed changes

Copilot reviewed 94 out of 94 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/tests/ContentProcessorWorkflow/utils/test_prompt_util.py Adds unit tests for Jinja2 template rendering utility.
src/tests/ContentProcessorWorkflow/utils/test_logging_utils_extended.py Adds additional logging utility tests to raise coverage.
src/tests/ContentProcessorWorkflow/utils/test_logging_utils.py Adds baseline logging utility unit tests.
src/tests/ContentProcessorWorkflow/utils/test_http_simple.py Adds basic HTTP helper tests (coverage-driven).
src/tests/ContentProcessorWorkflow/utils/test_http_request_utils.py Adds parameterized tests for URL join + Retry-After parsing helpers.
src/tests/ContentProcessorWorkflow/utils/test_credential_util.py Adds tests for Azure credential selection utilities.
src/tests/ContentProcessorWorkflow/steps/test_summarize_executor.py Tests summarize executor prompt file loading paths/errors.
src/tests/ContentProcessorWorkflow/steps/test_step_models.py Adds tests for Pydantic workflow step models.
src/tests/ContentProcessorWorkflow/steps/test_gap_executor.py Tests GAP executor prompt/rules loading and YAML validation behavior.
src/tests/ContentProcessorWorkflow/steps/test_claim_processor.py Tests workflow exception types and serialization behavior.
src/tests/ContentProcessorWorkflow/services/test_queue_service_stop_service.py Tests queue service stop-service task cancellation/cleanup.
src/tests/ContentProcessorWorkflow/services/test_queue_service_stop_process.py Tests stop-process message deletion, cleanup, and cancellation.
src/tests/ContentProcessorWorkflow/services/test_queue_service_failure_cleanup.py Tests failure handling, DLQ routing, and cleanup logic.
src/tests/ContentProcessorWorkflow/services/test_queue_message_parsing.py Tests queue message parsing (JSON/base64/validation).
src/tests/ContentProcessorWorkflow/services/test_content_process_models.py Adds tests for workflow content process models.
src/tests/ContentProcessorWorkflow/repositories/test_claim_processes_repository.py Adds tests for repository CRUD/upsert helpers using AsyncMock.
src/tests/ContentProcessorWorkflow/repositories/test_claim_process_model.py Adds tests for repository domain models and defaults.
src/tests/ContentProcessorWorkflow/pytest.ini Introduces workflow pytest discovery/markers configuration.
src/tests/ContentProcessorWorkflow/libs/test_ultra_focused_80.py Adds targeted “coverage push” tests (notably coverage-driven).
src/tests/ContentProcessorWorkflow/libs/test_final_coverage_boost.py Adds additional coverage-driven tests across libs/utils.
src/tests/ContentProcessorWorkflow/libs/test_final_80_percent_push.py Adds more coverage-driven tests for edge branches.
src/tests/ContentProcessorWorkflow/libs/test_advanced_coverage.py Adds additional coverage tests for HTTP/logging/DI branches.
src/tests/ContentProcessorWorkflow/libs/base/test_ApplicationBase.py Adds very basic assertions for ApplicationBase presence.
src/tests/ContentProcessorWorkflow/libs/azure/test_app_configuration_helper.py Adds unit tests for Azure App Configuration helper.
src/tests/ContentProcessorWorkflow/libs/application/test_service_config.py Adds tests for ServiceConfig validation and serialization.
src/tests/ContentProcessorWorkflow/libs/application/test_env_configuration.py Adds tests for env-based configuration loading.
src/tests/ContentProcessorWorkflow/libs/application/test_application_context_di.py Adds DI lifetime behavior tests (singleton/transient/scoped/async).
src/tests/ContentProcessorWorkflow/libs/application/test_application_configuration.py Adds tests for Configuration env alias and boolean parsing.
src/tests/ContentProcessorWorkflow/libs/application/test_AppConfiguration.py Adds tests for Configuration defaults.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_mem0_async_memory.py Adds tests for async memory manager caching behavior.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_input_observer_middleware.py Adds tests for InputObserverMiddleware message replacement.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_groupchat_orchestrator_termination.py Adds tests for orchestrator termination + loop detection.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_cosmos_checkpoint_storage.py Adds tests for Cosmos checkpoint storage adapter/repo delegation.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_speaking_capture.py Adds tests for capturing agent responses and callback wiring.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_info.py Adds tests for AgentInfo template rendering behavior.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_framework_settings.py Adds tests for service discovery + env file loading behavior.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_framework_helper.py Adds tests for agent framework helper initialization + client creation.
src/tests/ContentProcessorWorkflow/libs/agent_framework/test_agent_builder.py Adds tests for fluent AgentBuilder API and build delegation.
src/tests/ContentProcessorWorkflow/conftest.py Adds sys.path wiring so workflow tests import workflow src tree.
src/tests/ContentProcessorWorkflow/README.md Adds documentation for workflow tests (currently formatted as a Python docstring).
src/tests/ContentProcessorWorkflow/COVERAGE_README.md Adds guidance for running “core logic” coverage.
src/tests/ContentProcessorWorkflow/.coveragerc Adds coverage include/omit rules for workflow component.
src/tests/ContentProcessorAPI/pytest.ini Adds pytest discovery/markers config for API tests.
src/tests/ContentProcessorAPI/libs/test_storage_queue_helper.py Adds unit tests for storage queue helper with mocks.
src/tests/ContentProcessorAPI/libs/test_cosmos_db_helper.py Adds unit tests for Cosmos Mongo helper with mocks.
src/tests/ContentProcessorAPI/libs/test_app_configuration_helper.py Adds unit tests for API AppConfigurationHelper behavior.
src/tests/ContentProcessorAPI/helpers/test_azure_credential_utils.py Adds tests for API azure credential utility selection logic.
src/tests/ContentProcessorAPI/conftest.py Adds sys.path wiring + default env var setup for API tests.
src/tests/ContentProcessorAPI/README.md Adds documentation for API tests (currently formatted as a Python docstring).
src/tests/ContentProcessorAPI/.coveragerc Adds coverage configuration for API component.
src/tests/ContentProcessor/utils/test_utils.py Adds unit tests for backend utility helpers (encoder/flatten/match/contains).
src/tests/ContentProcessor/utils/test_stopwatch.py Adds unit tests for Stopwatch behavior.
src/tests/ContentProcessor/utils/test_base64_util.py Adds unit tests for base64 utility validation.
src/tests/ContentProcessor/utils/test_azure_credential_utils.py Adds unit tests for backend azure credential utilities with patching.
src/tests/ContentProcessor/pytest.ini Adds pytest discovery/markers config for backend tests.
src/tests/ContentProcessor/process_host/test_handler_type_loader.py Adds tests for dynamic handler import/load behavior.
src/tests/ContentProcessor/pipeline/test_schema.py Adds tests for Schema model construction + Cosmos lookup behavior.
src/tests/ContentProcessor/pipeline/test_queue_handler_base.py Adds tests for HandlerBase subclass behavior and queue info.
src/tests/ContentProcessor/pipeline/test_pipeline_step_result.py Adds tests for StepResult defaults and persistence guards.
src/tests/ContentProcessor/pipeline/test_pipeline_step_helper.py Adds tests for pipeline step navigation helper.
src/tests/ContentProcessor/pipeline/test_pipeline_status.py Adds tests for PipelineStatus step/result tracking.
src/tests/ContentProcessor/pipeline/test_pipeline_queue_helper.py Adds tests for pipeline queue helper operations and naming.
src/tests/ContentProcessor/pipeline/test_pipeline_message_base.py Adds tests for exception serialization on pipeline messages.
src/tests/ContentProcessor/pipeline/test_pipeline_file.py Adds tests for artifact/file detail/log entry models.
src/tests/ContentProcessor/pipeline/test_pipeline_data.py Adds tests for DataPipeline helpers and JSON parsing.
src/tests/ContentProcessor/pipeline/test_mime_types.py Adds tests for MIME constants and detection behavior.
src/tests/ContentProcessor/pipeline/test_evaluate_model.py Adds tests for evaluation result container serialization.
src/tests/ContentProcessor/pipeline/test_confidence.py Adds tests for confidence extraction/merge logic.
src/tests/ContentProcessor/pipeline/test_comparison.py Adds tests for extraction comparison models and builder function.
src/tests/ContentProcessor/libs/test_utils_coverage_boost.py Adds additional “coverage push” tests for utilities.
src/tests/ContentProcessor/libs/test_models_and_entities.py Adds broad “coverage push” tests for multiple models/entities.
src/tests/ContentProcessor/libs/test_final_push_80.py Adds additional “coverage push” tests targeting remaining gaps.
src/tests/ContentProcessor/libs/test_complete_utils_coverage.py Adds extensive tests to raise utility coverage (some assertions are weak).
src/tests/ContentProcessor/conftest.py Adds sys.path wiring for backend tests.
src/tests/ContentProcessor/base/test_application_models.py Adds tests for shared Pydantic base models/settings.
src/tests/ContentProcessor/azure_helper/test_storage_blob.py Adds tests for StorageBlobHelper methods using mocks.
src/tests/ContentProcessor/azure_helper/test_cosmos_mongo.py Adds mongomock-backed tests for Cosmos Mongo helper.
src/tests/ContentProcessor/azure_helper/test_content_understanding_model.py Adds tests for content understanding response models.
src/tests/ContentProcessor/application/test_service_config.py Adds tests for backend ServiceConfig.
src/tests/ContentProcessor/application/test_application_configuration.py Adds tests for AppConfiguration.split_processes validator.
src/tests/ContentProcessor/README.md Adds documentation for backend tests (currently formatted as a Python docstring).
src/tests/ContentProcessor/.coveragerc Adds coverage configuration for backend component.
.github/workflows/test.yml Splits CI into backend/api/workflow jobs; updates Python version; adjusts test discovery and coverage commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tests/ContentProcessorWorkflow/utils/test_http_simple.py
@Prajwal-Microsoft Prajwal-Microsoft merged commit e676354 into dev Apr 20, 2026
13 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants