Skip to content

Commit

Permalink
Add some join tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pliner committed Oct 29, 2024
1 parent bac0bbe commit f46b0b7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import yarl


@pytest.mark.parametrize(
"base, relative, actual",
(
("http://service.com", "hello", "http://service.com/hello"),
("http://service.com/", "hello", "http://service.com/hello"),
("http://service.com", "api/hello", "http://service.com/api/hello"),
("http://service.com/", "api/hello", "http://service.com/api/hello"),
("http://service.com", "hello", "http://service.com/hello"),
("http://service.com/", "hello", "http://service.com/hello"),
("http://service.com", "api/hello", "http://service.com/api/hello"),
("http://service.com/", "api/hello", "http://service.com/api/hello"),
("https://service.com", "hello", "https://service.com/hello"),
("https://service.com/", "hello", "https://service.com/hello"),
("https://service.com", "api/hello", "https://service.com/api/hello"),
("https://service.com/", "api/hello", "https://service.com/api/hello"),
("https://service.com:12345", "hello", "https://service.com:12345/hello"),
("https://service.com:12345/", "hello", "https://service.com:12345/hello"),
("https://service.com:12345", "api/hello", "https://service.com:12345/api/hello"),
("https://service.com:12345/", "api/hello", "https://service.com:12345/api/hello"),
),
)
async def test_absolute(base: str, relative: str, actual) -> None:
expected = yarl.URL(base).join(yarl.URL(relative))
assert expected == yarl.URL(actual)
assert expected.raw_path.startswith("/")

0 comments on commit f46b0b7

Please sign in to comment.