-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add get port functionality * Fix style in tests * Update behave and share code * Pass extractor to the private function
- Loading branch information
Showing
2 changed files
with
73 additions
and
14 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,29 @@ | ||
from domain_utils import get_port | ||
|
||
|
||
def test_no_port(): | ||
assert get_port('domain.net') is None | ||
|
||
|
||
def test_port_in_ip(): | ||
assert get_port('10.0.0.1:80/path/to/index.html') == 80 | ||
|
||
|
||
def test_port_in_url(): | ||
assert get_port('example.com:80/path/to/index.html') == 80 | ||
|
||
|
||
def test_port_in_domain(): | ||
assert get_port('example.com:5000') == 5000 | ||
|
||
|
||
def test_port_in_ip_no_path(): | ||
assert get_port('10.0.0.1:80') == 80 | ||
|
||
|
||
def test_port_no_tld(): | ||
assert get_port('localhost:8000') == 8000 | ||
|
||
|
||
def test_url_with_protocol(): | ||
assert get_port('ws://example.com:5000') == 5000 |