mirror of
https://github.com/Hopiu/bowser.git
synced 2026-03-16 19:10:24 +00:00
- Removed unused imports from various test files to streamline code. - Cleaned up whitespace in test cases for better consistency. - Updated dependency management in `uv.lock` to reflect changes in optional dependencies. - Ensured all tests maintain functionality while enhancing clarity and organization.
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Tests for URL parsing and resolution."""
|
|
|
|
from src.network.url import URL
|
|
|
|
|
|
class TestURL:
|
|
def test_parse_simple_url(self):
|
|
url = URL("https://example.com")
|
|
assert str(url) == "https://example.com"
|
|
|
|
def test_parse_url_with_path(self):
|
|
url = URL("https://example.com/path/to/page")
|
|
assert str(url) == "https://example.com/path/to/page"
|
|
|
|
def test_parse_url_with_query(self):
|
|
url = URL("https://example.com/search?q=test")
|
|
assert str(url) == "https://example.com/search?q=test"
|
|
|
|
def test_origin(self):
|
|
url = URL("https://example.com:8080/path")
|
|
assert url.origin() == "https://example.com:8080"
|
|
|
|
def test_origin_default_port(self):
|
|
url = URL("https://example.com/path")
|
|
assert url.origin() == "https://example.com"
|
|
|
|
def test_resolve_relative_path(self):
|
|
base = URL("https://example.com/dir/page.html")
|
|
resolved = base.resolve("other.html")
|
|
assert str(resolved) == "https://example.com/dir/other.html"
|
|
|
|
def test_resolve_absolute_path(self):
|
|
base = URL("https://example.com/dir/page.html")
|
|
resolved = base.resolve("/root/page.html")
|
|
assert str(resolved) == "https://example.com/root/page.html"
|
|
|
|
def test_resolve_full_url(self):
|
|
base = URL("https://example.com/page.html")
|
|
resolved = base.resolve("https://other.com/page.html")
|
|
assert str(resolved) == "https://other.com/page.html"
|