2021-06-11 08:18:39 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2021 ypsilik <tt2laurent.maud@gmail.com>, et al.
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2022-02-22 21:01:27 +00:00
|
|
|
lxml_available = True
|
|
|
|
try:
|
|
|
|
import lxml
|
|
|
|
except ImportError:
|
|
|
|
lxml_available = False
|
|
|
|
|
|
|
|
pytestmark = [
|
2023-12-09 11:17:31 +00:00
|
|
|
pytest.mark.asyncio(scope="session"),
|
2022-02-22 21:01:27 +00:00
|
|
|
pytest.mark.needs_net,
|
|
|
|
pytest.mark.skipif(not lxml_available, reason="needs lxml"),
|
|
|
|
]
|
2021-06-11 08:18:39 +00:00
|
|
|
|
|
|
|
async def test_xpath_ok(get_version):
|
2023-06-01 16:58:24 +00:00
|
|
|
ver = await get_version("aur", {
|
2021-06-11 08:18:39 +00:00
|
|
|
"source": "htmlparser",
|
2023-06-01 16:58:24 +00:00
|
|
|
"url": "https://aur.archlinux.org/",
|
|
|
|
"xpath": '//div[@id="footer"]/p[1]/a/text()',
|
|
|
|
})
|
|
|
|
assert ver.startswith('v')
|
|
|
|
assert '.' in ver
|
2022-06-12 04:31:11 +00:00
|
|
|
|
|
|
|
async def test_xpath_element(get_version):
|
2023-06-01 16:58:24 +00:00
|
|
|
ver = await get_version("aur", {
|
2022-06-12 04:31:11 +00:00
|
|
|
"source": "htmlparser",
|
2023-06-01 16:58:24 +00:00
|
|
|
"url": "https://aur.archlinux.org/",
|
|
|
|
"xpath": '//div[@id="footer"]/p[1]/a',
|
|
|
|
})
|
|
|
|
assert ver.startswith('v')
|
|
|
|
assert '.' in ver
|
2022-06-12 04:31:11 +00:00
|
|
|
|