Skip to content

test: add unit tests for parse_vercel_url to extract log and deployme…#1148

Merged
VaibhavUpreti merged 3 commits intoTracer-Cloud:mainfrom
zeesshhh0:fix/add_test_parse_vercel_url_extra_querys
Apr 30, 2026
Merged

test: add unit tests for parse_vercel_url to extract log and deployme…#1148
VaibhavUpreti merged 3 commits intoTracer-Cloud:mainfrom
zeesshhh0:fix/add_test_parse_vercel_url_extra_querys

Conversation

@zeesshhh0
Copy link
Copy Markdown
Contributor

Fixes #1122

Summary

This PR completes the test coverage for the parse_vercel_url() function in the Vercel poller. Previously, the parser supported multiple query aliases for log and deployment IDs, but only part of that behavior was covered by automated tests.

This update adds the missing assertions to guarantee the parser handles all supported variations, handles messy input, and preserves the original URL string.

Changes made:

  • Added tests for the following query parameters:
    • logId
    • selectedLog
    • deploymentId
    • deployment_id
  • Added assertions to verify that the parser correctly trims leading and trailing whitespace from the URL string.
  • Added assertions to confirm the original URL remains intact after parsing.

All tests pass locally. You can verify the coverage by running:

python -m pytest tests/app/remote/test_vercel_poller.py -q

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR adds 5 unit tests for parse_vercel_url() to cover the logId, selectedLog, deploymentId, and deployment_id query-parameter aliases, plus a whitespace-trimming assertion — all of which are correct against the current implementation.

  • The first four new test functions are separated by only one blank line instead of two, which will fail ruff E302 and block make lint / make format-check (both are CI gates). Running make format locally will fix this automatically.

Confidence Score: 4/5

Safe to merge once the blank-line formatting is fixed; the test logic itself is correct.

All five new assertions correctly reflect the implementation. The only blocking issue is a formatting violation (single blank lines between top-level functions) that will fail the ruff CI gate — easily fixed with make format.

tests/app/remote/test_vercel_poller.py — fix blank lines between the four new test functions before the whitespace test.

Important Files Changed

Filename Overview
tests/app/remote/test_vercel_poller.py Adds 5 new unit tests covering logId, selectedLog, deploymentId, deployment_id query params and whitespace trimming; all assertions are correct against the implementation, but single-blank-line separators between the first four new functions will fail ruff E302 and block CI.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["parse_vercel_url(url)"] --> B["cleaned = url.strip()"]
    B --> C["urlparse(cleaned)"]
    C --> D["Extract path segments\n(team_slug, project_slug, deployment_id)"]
    C --> E["parse_qs(query)"]
    E --> F{"selected_log_id?"}
    F -->|"selectedLogId"| G["selected_log_id = selectedLogId"]
    F -->|"logId"| H["selected_log_id = logId"]
    F -->|"selectedLog"| I["selected_log_id = selectedLog"]
    E --> J{"deployment_id?"}
    J -->|"path segment"| K["deployment_id from path"]
    J -->|"deploymentId"| L["deployment_id = deploymentId"]
    J -->|"deployment_id"| M["deployment_id = deployment_id"]
    G & H & I --> N["ParsedVercelUrl\n(original_url=cleaned, ...)"]
    K & L & M --> N
    D --> N
    style G fill:#d4edda
    style H fill:#d4edda
    style I fill:#d4edda
    style L fill:#d4edda
    style M fill:#d4edda
Loading

Reviews (1): Last reviewed commit: "test: add unit tests for parse_vercel_ur..." | Re-trigger Greptile

Comment thread tests/app/remote/test_vercel_poller.py
Comment thread tests/app/remote/test_vercel_poller.py Outdated
Comment on lines +373 to +379
def test_parse_vercel_url_trims_whitespace_keeps_original_url() -> None:
parsed = parse_vercel_url(
" https://vercel.com/vincenthus-projects/tracer-marketing-website-v3/logs?page=3&logId=54w4s-1775494460431-b04b1df81301 "
)

assert parsed.selected_log_id == "54w4s-1775494460431-b04b1df81301"
assert parsed.original_url == "https://vercel.com/vincenthus-projects/tracer-marketing-website-v3/logs?page=3&logId=54w4s-1775494460431-b04b1df81301"
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.

P2 Test name implies preservation of raw input, but asserts the stripped value

The test name test_parse_vercel_url_trims_whitespace_keeps_original_url could mislead future readers: original_url stores vercel_url.strip(), not the verbatim input. The assertion is correct against the current implementation, but the name suggests the original (whitespace-padded) string is preserved. Consider renaming to test_parse_vercel_url_trims_whitespace_and_stores_cleaned_url for clarity.

Context Used: Testing conventions and patterns (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

zeesshhh0 and others added 2 commits April 30, 2026 19:47
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@VaibhavUpreti VaibhavUpreti left a comment

Choose a reason for hiding this comment

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

Great job @zeesshhh0 , thanks a lot for fixing this!

@VaibhavUpreti VaibhavUpreti merged commit f778075 into Tracer-Cloud:main Apr 30, 2026
6 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🍵 @zeesshhh0 made tea, opened a PR, and merged before it cooled. No notes. ☕


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

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 parse_vercel_url() coverage for extra query variants

2 participants