-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
752 additions
and
360 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,9 @@ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.eggs | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.*cache | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
.vscode | ||
.cache | ||
dist | ||
*.lock | ||
__pycache__ | ||
*.pyc | ||
*.egg-info |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
language: python | ||
sudo: required | ||
dist: xenial | ||
python: | ||
- "3.6" | ||
- "2.7" | ||
- "3.7" | ||
install: | ||
- "pip install coverage" | ||
- "pip install coveralls" | ||
script: | ||
- "coverage run --source=url_normalize setup.py test" | ||
after_success: | ||
coveralls | ||
- "pip install coveralls poetry" | ||
- "poetry install -v" | ||
script: "pytest" | ||
after_success: coveralls |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tox: | ||
@tox | ||
|
||
test: | ||
@py.test | ||
|
||
build: | ||
@poetry build | ||
|
||
publish: build | ||
@poetry publish |
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,25 @@ | ||
[tool.poetry] | ||
name = "url-normalize" | ||
version = "1.4.0" | ||
description = "URL normalization for Python" | ||
authors = ["Nikolay Panov <[email protected]>"] | ||
license = "PSF" | ||
readme = "README.md" | ||
repository = "https://github.com/niksite/url-normalize" | ||
homepage = "https://github.com/niksite/url-normalize" | ||
keywords = ['url', 'normalization', 'normalize'] | ||
|
||
[tool.poetry.dependencies] | ||
python = "~2.7 || ^3.6" | ||
six = "^1.11" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^3.0" | ||
pytest-cov = "^2.6" | ||
tox = "^3.5" | ||
pytest-flakes = "^4.0" | ||
pytest-socket = "^0.3.1" | ||
|
||
[build-system] | ||
requires = ["poetry>=0.12"] | ||
build-backend = "poetry.masonry.api" |
Empty file.
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,32 @@ | ||
"""Deconstruct url tests.""" | ||
from url_normalize.tools import deconstruct_url, URL | ||
|
||
EXPECTED_DATA = { | ||
"http://site.com": URL( | ||
fragment="", | ||
host="site.com", | ||
path="", | ||
port="", | ||
query="", | ||
scheme="http", | ||
userinfo="", | ||
), | ||
"http://[email protected]:8080/path/index.html?param=val#fragment": URL( | ||
fragment="fragment", | ||
host="www.example.com", | ||
path="/path/index.html", | ||
port="8080", | ||
query="param=val", | ||
scheme="http", | ||
userinfo="user@", | ||
), | ||
} | ||
|
||
|
||
def test_deconstruct_url_result_is_expected(): | ||
"""Assert we got expected results from the deconstruct_url function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = deconstruct_url(url) | ||
|
||
assert result == expected, url |
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,20 @@ | ||
"""Tests for generic_url_cleanup function.""" | ||
from url_normalize.url_normalize import generic_url_cleanup | ||
|
||
EXPECTED_DATA = { | ||
"//site/#!fragment": "//site/?_escaped_fragment_=fragment", | ||
"//site/?utm_source=some source¶m=value": "//site/?param=value", | ||
"//site/?utm_source=some source": "//site/", | ||
"//site/?param=value&utm_source=some source": "//site/?param=value", | ||
"//site/page": "//site/page", | ||
"//site/?& ": "//site/", | ||
} | ||
|
||
|
||
def test_generic_url_cleanup_result_is_expected(): | ||
"""Assert we got expected results from the generic_url_cleanup function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = generic_url_cleanup(url) | ||
|
||
assert result == expected, url |
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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for normalize_fragment function.""" | ||
from url_normalize.url_normalize import normalize_fragment | ||
|
||
EXPECTED_DATA = { | ||
"": "", | ||
"fragment": "fragment", | ||
"пример": "%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80", | ||
"!fragment": "%21fragment", | ||
"~fragment": "~fragment", | ||
} | ||
|
||
|
||
def test_normalize_fragment_result_is_expected(): | ||
"""Assert we got expected results from the normalize_fragment function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_fragment(url) | ||
|
||
assert result == expected, url |
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for normalize_host function.""" | ||
from url_normalize.url_normalize import normalize_host | ||
|
||
EXPECTED_DATA = { | ||
"site.com": "site.com", | ||
"SITE.COM": "site.com", | ||
"site.com.": "site.com", | ||
"пример.испытание": "xn--e1afmkfd.xn--80akhbyknj4f", | ||
} | ||
|
||
|
||
def test_normalize_host_result_is_expected(): | ||
"""Assert we got expected results from the normalize_host function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_host(url) | ||
|
||
assert result == expected, url |
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,39 @@ | ||
"""Tests for normalize_path function.""" | ||
from url_normalize.url_normalize import normalize_path | ||
|
||
EXPECTED_DATA = { | ||
"": "/", | ||
"/": "/", | ||
"..": "/", | ||
"/foo/bar/.": "/foo/bar/", | ||
"/foo/bar/./": "/foo/bar/", | ||
"/foo/bar/..": "/foo/", | ||
"/foo/bar/../": "/foo/", | ||
"/foo/bar/../baz": "/foo/baz", | ||
"/foo/bar/../..": "/", | ||
"/foo/bar/../../": "/", | ||
"/foo/bar/../../baz": "/baz", | ||
"/foo/bar/../../../baz": "/baz", | ||
"/foo/bar/../../../../baz": "/baz", | ||
"/./foo": "/foo", | ||
"/../foo": "/foo", | ||
"/foo.": "/foo.", | ||
"/.foo": "/.foo", | ||
"/foo..": "/foo..", | ||
"/..foo": "/..foo", | ||
"/./../foo": "/foo", | ||
"/./foo/.": "/foo/", | ||
"/foo/./bar": "/foo/bar", | ||
"/foo/../bar": "/bar", | ||
"/foo//": "/foo/", | ||
"/foo///bar//": "/foo/bar/", | ||
} | ||
|
||
|
||
def test_normalize_host_result_is_expected(): | ||
"""Assert we got expected results from the normalize_path function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_path(url, "http") | ||
|
||
assert result == expected, url |
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,13 @@ | ||
"""Tests for normalize_port function.""" | ||
from url_normalize.url_normalize import normalize_port | ||
|
||
EXPECTED_DATA = {"8080": "8080", "": "", "80": "", "string": "string"} | ||
|
||
|
||
def test_normalize_port_result_is_expected(): | ||
"""Assert we got expected results from the normalize_port function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_port(url, "http") | ||
|
||
assert result == expected, url |
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,21 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for normalize_query function.""" | ||
|
||
from url_normalize.url_normalize import normalize_query | ||
|
||
EXPECTED_DATA = { | ||
"": "", | ||
"param1=val1¶m2=val2": "param1=val1¶m2=val2", | ||
"Ç=Ç": "%C3%87=%C3%87", | ||
"%C3%87=%C3%87": "%C3%87=%C3%87", | ||
"q=C%CC%A7": "q=%C3%87", | ||
} | ||
|
||
|
||
def test_normalize_query_result_is_expected(): | ||
"""Assert we got expected results from the normalize_query function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_query(url) | ||
|
||
assert result == expected, url |
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,13 @@ | ||
"""Tests for normalize_scheme function.""" | ||
from url_normalize.url_normalize import normalize_scheme | ||
|
||
EXPECTED_DATA = {"http": "http", "HTTP": "http"} | ||
|
||
|
||
def test_normalize_scheme_result_is_expected(): | ||
"""Assert we got expected results from the normalize_scheme function.""" | ||
for url, expected in EXPECTED_DATA.items(): | ||
|
||
result = normalize_scheme(url) | ||
|
||
assert result == expected, url |
Oops, something went wrong.