-
Notifications
You must be signed in to change notification settings - Fork 0
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
_eternal_flame
authored and
_eternal_flame
committed
May 30, 2018
1 parent
1ecc5ef
commit f4b58b2
Showing
2 changed files
with
52 additions
and
3 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,33 @@ | ||
import os | ||
import sys | ||
|
||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
sys.path.insert(0, parentdir) | ||
|
||
from pxelem import PixlvUrl | ||
|
||
class TestUrlParse(): | ||
|
||
def test_simple_url(self): | ||
url=PixlvUrl("https://www.example.com", use_english=False) | ||
assert url.getscheme()=="https" | ||
assert url.gethost()=="www.example.com" | ||
assert url.getquerydict()=={} | ||
assert url.geturi()=="/" | ||
|
||
def test_query_string(self): | ||
url=PixlvUrl("https://www.example.com/query.php?param1=abc¶m2=123", use_english=False) | ||
assert url.getquerydict()["param1"][0]=="abc" | ||
url.addquerystring("param3", "456") | ||
assert url.getquerydict()["param3"][0]=="456" | ||
url.addquerystring("param3", "789") | ||
assert url.getquerydict()["param3"][0]=="789" | ||
assert url.geturl()=="https://www.example.com/query.php?param1=abc¶m2=123¶m3=789" | ||
|
||
def test_port_detection(self): | ||
url=PixlvUrl("https://www.example.com") | ||
assert url.getport()==443 | ||
url=PixlvUrl("http://www.example.com") | ||
assert url.getport()==80 | ||
url=PixlvUrl("https://www.example.com:444") | ||
assert url.getport()==444 |