-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove validators dependency from Python SDK
- Loading branch information
Showing
6 changed files
with
96 additions
and
33 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
29 changes: 1 addition & 28 deletions
29
generator/konfig-generator-api/src/main/resources/python/poetry.lock.handlebars
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
generator/konfig-generator-api/src/main/resources/python/settings.json.handlebars
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,9 @@ | ||
{ | ||
"python.testing.pytestArgs": [], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
}, | ||
"python.formatting.provider": "none" | ||
} |
75 changes: 75 additions & 0 deletions
75
generator/konfig-generator-api/src/main/resources/python/test_check_url.handlebars
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,75 @@ | ||
# coding: utf-8 | ||
|
||
{{>partial_header}} | ||
|
||
import unittest | ||
from {{packageName}}.configuration import check_url | ||
from {{packageName}}.exceptions import InvalidHostConfigurationError | ||
|
||
|
||
class TestIsValidUrl(unittest.TestCase): | ||
def test_valid_urls(self): | ||
valid_urls = [ | ||
"http://www.example.com", | ||
"https://www.example.com", | ||
"http://example.com", | ||
"https://example.com/path/to/resource", | ||
"http://example.com:8080", | ||
"https://example.co.uk", | ||
"https://subdomain.example.com", | ||
"https://api.example.com/v1/resource", | ||
"https://example.com/path/to/resource/123", | ||
"https://www.example.com:8080", | ||
"https://www.example.com:8080/path/to/resource", | ||
"http://sub.example.com:8080", | ||
"http://deep.sub.domain.example.com", | ||
"http://127.0.0.1:4010", | ||
"https://deep.sub.domain.example.com:8080/path", | ||
"http://example.io", | ||
"https://example.app", | ||
] | ||
for url in valid_urls: | ||
with self.subTest(url=url): | ||
self.assertTrue(check_url(url)) | ||
|
||
def test_invalid_urls(self): | ||
invalid_urls = [ | ||
"not_a_url", | ||
"http:/example.com", | ||
"http://", | ||
"http://.com", | ||
"example.com", | ||
"http://example.com#fragment", | ||
"www.example.com", | ||
"https://example.com/path/to/resource?query=value", | ||
"https://example.com/path/to/resource?query=value&key2=value2", | ||
"https://", | ||
"ftp://files.example.com", | ||
"//example.com", | ||
"https://example,com", | ||
"https:/example.com", | ||
"https:// example.com", | ||
"https://example.com path", | ||
"http://..com", | ||
"https://..example.com", | ||
"http://example..com", | ||
"https://example.com./path", | ||
"https://example.com..", | ||
"http://:8080", | ||
"https://example.com:", | ||
"http://example.com:abc", | ||
"https://.example.com", | ||
"http://example.", | ||
"https:// example:8080.com", | ||
"http:// example.com:8080/path", | ||
"https://:8080/path", | ||
] | ||
for url in invalid_urls: | ||
with self.subTest(url=url): | ||
with self.assertRaises(InvalidHostConfigurationError): | ||
check_url(url) | ||
raise Exception("URL should be invalid: " + url) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |