-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add datastar_py.url helper
#58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kdheepak
wants to merge
5
commits into
starfederation:develop
Choose a base branch
from
kdheepak:kd/datastar_url
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d8c753
feat: add datastar_url helper
kdheepak 329c4f5
feat(version): accept major and minor values in datastar_url
kdheepak 59062c7
test(datastar-url): add coverage for version parsing and validation
kdheepak 689f3e6
refactor(api): rename datastar_url to url
kdheepak d508a77
docs(readme): use datastar_py url helper in script src
kdheepak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import pytest | ||
|
|
||
| import datastar_py | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("version", "ref"), | ||
| ( | ||
| ("", ""), | ||
| ("1", "@v1"), | ||
| ("v1", "@v1"), | ||
| ("1.0", "@v1.0"), | ||
| ("v1.0", "@v1.0"), | ||
| ("1.0.4", "@v1.0.4"), | ||
| ("v1.0.4", "@v1.0.4"), | ||
| ("1.0.0-RC.7", "@v1.0.0-RC.7"), | ||
| ("v1.0.0-RC.7", "@v1.0.0-RC.7"), | ||
| ), | ||
| ) | ||
| def test_url_versions(version, ref): | ||
| assert datastar_py.url(version) == ( | ||
| f"https://cdn.jsdelivr.net/gh/starfederation/datastar{ref}/bundles/datastar.js" | ||
| ) | ||
|
|
||
|
|
||
| def test_url_default(): | ||
| assert datastar_py.url() == ( | ||
| "https://cdn.jsdelivr.net/gh/starfederation/datastar/bundles/datastar.js" | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "version", | ||
| ( | ||
| "v", | ||
| "v1.", | ||
| "1..0", | ||
| "1.0.4.1", | ||
| "1-RC.7", | ||
| "1.0-RC.7", | ||
| "1.0.4-", | ||
| "1.0.4-RC.", | ||
| "latest", | ||
| "v1/something", | ||
| "v1?x=1", | ||
| "v1#fragment", | ||
| ), | ||
| ) | ||
| def test_url_rejects_invalid_versions(version): | ||
| with pytest.raises(ValueError, match="version"): | ||
| datastar_py.url(version) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("version", (1, 1.0, True, b"v1", [], {})) | ||
| def test_url_rejects_invalid_types(version): | ||
| with pytest.raises(TypeError, match="version must be a string or None"): | ||
| datastar_py.url(version) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.