Skip to content

Add unit test coverage and CI coverage reporting#158

Merged
abelmilash-msft merged 19 commits intomainfrom
users/abelmilash/test_coverage
Apr 10, 2026
Merged

Add unit test coverage and CI coverage reporting#158
abelmilash-msft merged 19 commits intomainfrom
users/abelmilash/test_coverage

Conversation

@abelmilash-msft
Copy link
Copy Markdown
Contributor

@abelmilash-msft abelmilash-msft commented Apr 8, 2026

Summary

Adds comprehensive unit tests across 13 test files and enables coverage reporting and enforcement in both CI pipelines and pyproject.toml. Coverage increased from 72% to 93%.

Coverage enforcement is now built into both CI pipelines and the project config: overall coverage must stay at or above 90% (fail_under = 90 in pyproject.toml), and any new code introduced in a PR must also meet 90% (diff-cover).

Test Results

  • 1127 passed, 0 failures
  • 93% line coverage (up from ~72%)

Changes

Configuration (2 files)

  • pyproject.toml: Added [tool.coverage.run] (source = ["src/PowerPlatform"]) and [tool.coverage.report] (fail_under = 90, show_missing = true) to centralize coverage config
  • pyproject.toml: Added diff-cover dev dependency for PR-level coverage enforcement

CI Pipelines (2 files)

  • .github/workflows/python-package.yml: Added PYTHONPATH=src pytest --cov --cov-report=xml --junitxml=test-results.xml, diff-cover step to enforce 90% on new changes, fetch-depth: 0 for full git history, and artifact upload steps
  • .azdo/ci-pr.yaml: Same pytest and diff-cover steps, added PublishTestResults@2 and PublishCodeCoverageResults@2 tasks

New Test Files (6 files)

  • test_auth.py: Credential validation, token acquisition (2 tests)
  • test_http_client.py: Timeout selection, session routing, retry behavior (15 tests)
  • test_http_errors.py: Error response parsing, correlation IDs, transient detection (9 tests)
  • test_upload.py: File upload orchestrator, small upload, chunked streaming (50+ tests)
  • test_relationships.py: 1:N and M:N relationship CRUD (25+ tests)
  • test_records_operations.py: Public records API delegation (30+ tests)

Expanded Test Files (7 files)

  • test_odata_internal.py: 36 test classes, 219 tests covering all _ODataClient methods — CRUD, upsert, bulk operations, metadata, caching, picklist resolution, pagination, SQL queries, alternate keys, column management. Includes kwarg correctness audit (json= vs data=), response content validation, and assertion strengthening.
  • test_batch_serialization.py: 7 new test classes (26 tests) — dispatch routing for all intent types, changeset validation, metadata resolution, continue-on-error header, MIME parsing edge cases
  • test_query_builder.py, test_table_info.py, test_client.py, test_context_manager.py, test_records_operations.py: Docstrings added to existing tests

@abelmilash-msft abelmilash-msft requested a review from a team as a code owner April 8, 2026 17:55
Copilot AI review requested due to automatic review settings April 8, 2026 17:55
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 unit test suite to significantly increase coverage across the Dataverse client (including internal OData helpers), and updates both CI pipelines to publish JUnit test results and Cobertura-style coverage XML artifacts.

Changes:

  • Added extensive new unit tests for core HTTP/auth, OData internals, upload + relationship helpers, and public operation namespaces.
  • Extended existing unit tests to cover additional input validation and internal edge cases.
  • Updated GitHub Actions and Azure DevOps pipelines to emit and publish JUnit XML + coverage XML outputs.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/python-package.yml Runs pytest with JUnit + coverage reporting and uploads artifacts.
.azdo/ci-pr.yaml Runs pytest with JUnit + coverage reporting and publishes results in ADO.
tests/unit/core/test_auth.py Adds unit tests for credential validation + token acquisition.
tests/unit/core/test_http_client.py Adds unit tests for timeout defaults, session routing, and retry/backoff.
tests/unit/core/test_http_errors.py Adds instantiation tests for error types and optional HttpError diagnostic fields.
tests/unit/data/test_odata_internal.py Adds/extends broad internal _ODataClient coverage (CRUD, metadata, caching, etc.).
tests/unit/data/test_relationships.py Adds tests for relationship creation including solution header behavior.
tests/unit/data/test_upload.py Adds comprehensive tests for small/chunk upload paths and orchestration logic.
tests/unit/models/test_query_builder.py Adds a test for handling plain-string internal filter parts.
tests/unit/models/test_table_info.py Adds tests for non-string membership checks and legacy values/items behavior.
tests/unit/test_client.py Adds base URL validation test.
tests/unit/test_context_manager.py Adds delegation test for DataverseClient.flush_cache().
tests/unit/test_records_operations.py Adds input/type validation tests for RecordOperations CRUD behaviors.

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/test_coverage branch from d5ee154 to 9361629 Compare April 8, 2026 23:24
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… rendering

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sagebree sagebree left a comment

Choose a reason for hiding this comment

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

Ensure Azure DevOps pipeline approval is completed so coverage reporting is re-enabled

@abelmilash-msft abelmilash-msft merged commit 9cff47f into main Apr 10, 2026
10 checks passed
@abelmilash-msft abelmilash-msft deleted the users/abelmilash/test_coverage branch April 10, 2026 00:48
maksii added a commit to maksii/PowerPlatform-DataverseClient-Python that referenced this pull request Apr 10, 2026
Incorporate latest changes from microsoft/PowerPlatform-DataverseClient-Python:
- Batch API with changeset, upsert, and DataFrame integration (microsoft#129)
- Optimize picklist label resolution with bulk fetch (microsoft#154)
- Add memo/multiline column type support (microsoft#155)
- Add unit test coverage and CI coverage reporting (microsoft#158)

Made-with: Cursor
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.

3 participants