Skip to content

PYTHON-5773 Coverage increase for uri_parser_shared.py - #2758

Merged
aclark4life merged 4 commits into
mongodb:masterfrom
aclark4life:PYTHON-5773
May 27, 2026
Merged

aclark4life merged 4 commits into
mongodb:masterfrom
aclark4life:PYTHON-5773

Conversation

@aclark4life

@aclark4life aclark4life commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

PYTHON-5773

Changes in this PR

Add 12 new test methods to test_uri_parser.py covering previously untested branches:

  • _unquoted_percent direct branch coverage
  • parse_ipv6_literal_host direct branch coverage
  • parse_host case normalization and port boundaries
  • TLS option conflicts in _handle_security_options
  • Mixed option delimiters
  • Duplicate option warnings
  • Empty authSource rejection
  • _check_options conflicts (directConnection/loadBalanced)
  • validate_uri edge cases and SRV structural validation
  • Regression check that parse_uri(...)["options"] is a dict (PYTHON-5421)

Test Plan

uv run --extra test python -m pytest test/test_uri_parser.py -v

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 increases branch/line coverage for pymongo/uri_parser_shared.py by adding focused unit tests in test/test_uri_parser.py, targeting previously untested validation and option-parsing paths.

Changes:

  • Add direct tests for _unquoted_percent, parse_ipv6_literal_host, and parse_host (case normalization + port boundary handling).
  • Add tests for URI option parsing/validation edge cases (TLS conflicts, mixed delimiters, duplicate-option warnings, empty authSource).
  • Add tests for URI structural validation, including SRV-specific constraints and option incompatibilities.

@codecov-commenter

codecov-commenter commented Apr 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@aclark4life aclark4life changed the title PYTHON-5773 Increase uri_parser_shared.py coverage to 81% PYTHON-5773 Increase coverage for uri_parser_shared.py Apr 24, 2026
@aclark4life aclark4life changed the title PYTHON-5773 Increase coverage for uri_parser_shared.py PYTHON-5773 Increase code coverage for uri_parser_shared.py Apr 24, 2026
@aclark4life
aclark4life removed the request for review from caseyclements May 1, 2026 16:14
@aclark4life
aclark4life marked this pull request as draft May 6, 2026 18:22
@aclark4life
aclark4life requested a review from Copilot May 6, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread test/test_uri_parser.py Resolved
@aclark4life
aclark4life requested a review from Copilot May 7, 2026 02:02
@aclark4life aclark4life changed the title PYTHON-5773 Increase code coverage for uri_parser_shared.py PYTHON-5773 Improve code coverage for uri_parser_shared.py May 7, 2026
@aclark4life aclark4life changed the title PYTHON-5773 Improve code coverage for uri_parser_shared.py PYTHON-5773 Improve coverage for uri_parser_shared.py May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@aclark4life aclark4life changed the title PYTHON-5773 Improve coverage for uri_parser_shared.py PYTHON-5773 Improve coverage for uri_parser_shared.py May 7, 2026
@aclark4life aclark4life changed the title PYTHON-5773 Improve coverage for uri_parser_shared.py PYTHON-5773 Coverage improvements for uri_parser_shared.py May 7, 2026
@aclark4life aclark4life changed the title PYTHON-5773 Coverage improvements for uri_parser_shared.py PYTHON-5773 Coverage improvement for uri_parser_shared.py May 7, 2026
@aclark4life
aclark4life requested a review from Copilot May 7, 2026 02:29
@aclark4life aclark4life changed the title PYTHON-5773 Coverage improvement for uri_parser_shared.py PYTHON-5773 Coverage increase for uri_parser_shared.py May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@aclark4life
aclark4life marked this pull request as ready for review May 26, 2026 21:32
Add 11 new test methods to test_uri_parser.py covering previously
untested branches: _unquoted_percent, parse_ipv6_literal_host,
parse_host (case normalization and port boundaries), TLS option
conflicts in _handle_security_options, mixed option delimiters,
duplicate option warnings, empty authSource, _check_options
conflicts (directConnection/loadBalanced), and SRV URI structural
validation.

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@aclark4life
aclark4life merged commit 00cfe6f into mongodb:master May 27, 2026
84 of 85 checks passed
@aclark4life
aclark4life deleted the PYTHON-5773 branch May 27, 2026 17:12
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.

4 participants