Skip to content

feat(utils): add is_valid_url helper with pytest coverage - #79

Open
AJstyles903 wants to merge 1 commit into
clencyc:masterfrom
AJstyles903:feature/is-valid-url
Open

AJstyles903 wants to merge 1 commit into
clencyc:masterfrom
AJstyles903:feature/is-valid-url

Conversation

@AJstyles903

@AJstyles903 AJstyles903 commented Oct 27, 2026 •

Copy link
Copy Markdown

What does this PR do?

Adds the is_valid_url helper and its unit tests in one PR, as discussed in issue #31.

  • LiveEditBackend/utils/url.py: New is_valid_url() function that returns True only for HTTP(S) URLs with a non-empty hostname. Returns False for empty strings, non-strings, missing schemes, and other schemes (ftp, javascript, etc.).
  • LiveEditBackend/tests/test_url.py: Comprehensive pytest suite covering valid URLs, invalid URLs, and edge cases (None, empty string, missing scheme, other schemes).
  • pytest.ini: Added pythonpath = LiveEditBackend so flat imports (from utils.url import ...) resolve when pytest runs from repo root.

Closes #31

How did you test it?

  • Ran pytest LiveEditBackend/tests/test_url.py -v — all tests pass
  • Coverage for is_valid_url: [100]% ✅
  • No existing tests broken (full suite passes)
  • No __init__.py files added (follows repo's existing flat-import convention)
  • urlparse is Python stdlib — no new dependencies added

Checklist

  • This PR does one thing (one issue, one PR)
  • I ran the relevant tests locally (pytest in LiveEditBackend)
  • I added or updated tests where it makes sense

Summary by CodeRabbit

  • New Features
    • Added URL validation for HTTP and HTTPS addresses. Empty values, non-text inputs, unsupported schemes, malformed addresses, and addresses without a hostname are rejected.
  • Tests
    • Added coverage for accepted HTTP and HTTPS addresses and for invalid URL inputs.

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@AJstyles903 is attempting to deploy a commit to the ClaraClency Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for livedit canceled.

Name Link
🔨 Latest commit 3146da4
🔍 Latest deploy log https://app.netlify.com/projects/livedit/deploys/6ae06313b46c980b5ce80a28

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f62555d1-9bb3-42af-b3a4-2882b58e7e22
Commits

Reviewing files that changed from the base of the PR and between 88057a6 and 3146da4.

Files selected for processing: 3
  • LiveEditBackend/tests/test_url.py
  • LiveEditBackend/utils/url.py
  • pytest.ini

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The pull request adds is_valid_url, tests for accepted and rejected inputs, and pytest configuration that adds LiveEditBackend to the import path.

Changes: URL Validation

Layer / File(s) Summary
URL validation helper and tests
LiveEditBackend/utils/url.py, LiveEditBackend/tests/test_url.py, pytest.ini
Adds is_valid_url to accept HTTP or HTTPS URLs with a hostname and reject invalid inputs. Adds parameterized tests and configures pytest to include LiveEditBackend on the import path.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Possibly related PRs

  • clencyc/LiveEdit#77: Both PRs configure backend test imports by adding LiveEditBackend to the Python import path.

Suggested reviewers: clencyc

Merge Risk: Minimal · up to 3146d

No actionable merge-blocking risk is established for this test-only URL validation addition.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding the is_valid_url utility and pytest coverage.
Linked Issues check Passed Issue #31 requires tests for a valid URL, an invalid URL, and an empty string. The PR adds parameterized pytest cases in LiveEditBackend/tests/test_url.py. The implementation in `LiveEditBackend/uti…
Out of Scope Changes check Passed The changed files support issue #31. The helper implements the behavior under test. The pytest cases verify the required and stated edge cases. The pytest.ini pythonpath setting supports the repos…
Full details: Linked Issues check

Explanation

Issue #31 requires tests for a valid URL, an invalid URL, and an empty string. The PR adds parameterized pytest cases in LiveEditBackend/tests/test_url.py. The implementation in LiveEditBackend/utils/url.py covers HTTP(S), non-string, empty, unsupported-scheme, malformed, and scheme-less inputs. The PR reports local pytest execution and 100% function coverage, which exceeds the issue requirement of more than 90%.

Full details: Out of Scope Changes check

Explanation

The changed files support issue #31. The helper implements the behavior under test. The pytest cases verify the required and stated edge cases. The pytest.ini pythonpath setting supports the repository's flat-import test setup. No unrelated change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

Add a unit test for utils.is_valid_url

1 participant