-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_from_html.py
51 lines (36 loc) · 1.49 KB
/
test_from_html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from pyfavicon import Favicon, FaviconType
from pathlib import Path
import pytest
favicon = Favicon()
@pytest.mark.asyncio
async def test_link_tag():
files = [
Path('./tests/html/url_icon_link.html'),
Path('./tests/html/url_shortcut_icon_link.html'),
Path('./tests/html/url_apple_touch_icon_precomposed_link.html'),
Path('./tests/html/url_apple_touch_icon_link.html'),
Path('./tests/html/url_fluid_icon_link.html'),
]
for html_file in files:
icons = await favicon.from_file(html_file,
'https://github.com')
assert len(icons) != 0
icon = icons[0]
assert icon.type is FaviconType.URL
assert str(icon.link) == 'https://github.githubassets.com/favicon.ico'
@pytest.mark.asyncio
async def test_meta_tag():
html_file = Path('./tests/html/meta_favicon.html')
icons = await favicon.from_file(html_file, 'https://gitlab.com')
assert len(icons) != 0
icon = icons[0]
assert icon.type is FaviconType.URL
assert str(icon.link) == 'https://assets.gitlab-static.net/assets/msapplication-tile-1196ec67452f618d39cdd85e2e3a542f76574c071051ae7effbfde01710eb17d.png'
@pytest.mark.asyncio
async def test_largest_icon():
html_file = Path('./tests/html/largest_gitlab.html')
icons = await favicon.from_file(html_file)
assert len(icons) != 0
largest_icon = icons.get_largest()
assert largest_icon
assert largest_icon.size == (188, 188)