FixMiYouShe/tests/test_url.py
2024-05-10 22:06:34 +08:00

34 lines
1.1 KiB
Python

import pytest
from httpx import URL
from src.utils.url import parse_link
@pytest.mark.asyncio
class TestUrl:
@staticmethod
async def test_hoyolab_desktop():
url = URL("https://www.hoyolab.com/article/25091304")
real = parse_link(url)
assert real == URL("https://www.hoyolab.pp.ua/article/25091304")
@staticmethod
async def test_hoyolab_android():
url = URL(
"https://m.hoyolab.com/#/article/25091304?utm_source=sns&utm_medium=twitter&utm_id=2"
)
real = parse_link(url)
assert real == URL("https://www.hoyolab.pp.ua/article/25091304")
@staticmethod
async def test_miyoushe_desktop():
url = URL("https://www.miyoushe.com/sr/article/43966902")
real = parse_link(url)
assert real == URL("https://www.miyoushe.pp.ua/sr/article/43966902")
@staticmethod
async def test_miyoushe_android():
url = URL("https://m.miyoushe.com/sr?channel=beta/#/article/43966902")
real = parse_link(url)
assert real == URL("https://www.miyoushe.pp.ua/sr/article/43966902")