Coverage for tests/test_public.py: 100%
17 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-21 00:51 +0000
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-21 00:51 +0000
1import pytest
3from meta_tags_parser import public
6def test_public_download(monkeypatch: pytest.MonkeyPatch, provide_fake_meta: tuple[dict[str, str], str]) -> None:
7 """Test download via public API."""
9 # pylint: disable=too-few-public-methods
10 class FakeHttpXObject:
11 """Provide duck-typing mock."""
13 @property
14 def text(self) -> str:
15 """Return fake text.
17 Hello, duck-type
18 """
19 return provide_fake_meta[1]
21 monkeypatch.setattr("httpx.get", lambda _: FakeHttpXObject())
22 public.parse_tags_from_url("https://yandex.ru")
23 public.parse_snippets_from_url("https://yandex.ru")
26@pytest.mark.asyncio
27async def test_async_public_download(
28 monkeypatch: pytest.MonkeyPatch, provide_fake_meta: tuple[dict[str, str], str]
29) -> None:
30 """Test async download via public API."""
32 async def _fake_download(_: str) -> str:
33 return provide_fake_meta[1]
35 monkeypatch.setattr("meta_tags_parser.download.download_page_async", _fake_download)
36 await public.parse_tags_from_url_async("https://yandex.ru")
37 await public.parse_snippets_from_url_async("https://yandex.ru")