test: add unit tests for parse_vercel_url to extract log and deployme…#1148
Conversation
Greptile SummaryThis PR adds 5 unit tests for
Confidence Score: 4/5Safe 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 tests/app/remote/test_vercel_poller.py — fix blank lines between the four new test functions before the whitespace test. Important Files Changed
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
Reviews (1): Last reviewed commit: "test: add unit tests for parse_vercel_ur..." | Re-trigger Greptile |
| 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" |
There was a problem hiding this comment.
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!
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
VaibhavUpreti
left a comment
There was a problem hiding this comment.
Great job @zeesshhh0 , thanks a lot for fixing this!
|
🍵 @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. |

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:
logIdselectedLogdeploymentIddeployment_idAll tests pass locally. You can verify the coverage by running: