-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds tests for collection and is_url_valid
- Loading branch information
1 parent
7f4315f
commit e12a728
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,38 @@ | ||
import pytest | ||
|
||
from digital_land.commands import is_url_valid | ||
|
||
|
||
def test_is_url_valid(): | ||
isValid, error = is_url_valid("https://www.google.com", "URL") | ||
|
||
assert isValid | ||
assert error is None | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url, error_message", | ||
[ | ||
( | ||
"", | ||
"The URL must be populated", | ||
), | ||
( | ||
"www.google.com", | ||
"The URL must start with 'http://' or 'https://'", | ||
), | ||
( | ||
"https:///query=?a=1&b=2", | ||
"The URL must have a domain", | ||
), | ||
( | ||
"https://google", | ||
"The URL must have a valid domain with a top-level domain (e.g., '.gov.uk', '.com')", | ||
), | ||
], | ||
) | ||
def test_is_url_valid_error(url, error_message): | ||
isValid, error = is_url_valid(url, "URL") | ||
|
||
assert not isValid | ||
assert error == error_message |