mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-07 07:15:07 +01:00
Chore: add headers for wikipedia CI tests (#11253)
This commit is contained in:
parent
6f52614817
commit
cffb9c34f0
1 changed files with 14 additions and 1 deletions
|
|
@ -53,6 +53,15 @@ class TestUrlCanary:
|
||||||
Verify certain URLs are still available so testing is valid still
|
Verify certain URLs are still available so testing is valid still
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Wikimedia rejects requests without a browser-like User-Agent header and returns 403.
|
||||||
|
_WIKIMEDIA_HEADERS = {
|
||||||
|
"User-Agent": (
|
||||||
|
"Mozilla/5.0 (X11; Linux x86_64) "
|
||||||
|
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||||
|
"Chrome/123.0.0.0 Safari/537.36"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
def test_online_image_exception_on_not_available(self):
|
def test_online_image_exception_on_not_available(self):
|
||||||
"""
|
"""
|
||||||
GIVEN:
|
GIVEN:
|
||||||
|
|
@ -70,6 +79,7 @@ class TestUrlCanary:
|
||||||
with pytest.raises(httpx.HTTPStatusError) as exec_info:
|
with pytest.raises(httpx.HTTPStatusError) as exec_info:
|
||||||
resp = httpx.get(
|
resp = httpx.get(
|
||||||
"https://upload.wikimedia.org/wikipedia/en/f/f7/nonexistent.png",
|
"https://upload.wikimedia.org/wikipedia/en/f/f7/nonexistent.png",
|
||||||
|
headers=self._WIKIMEDIA_HEADERS,
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
|
|
||||||
|
|
@ -90,7 +100,10 @@ class TestUrlCanary:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Now check the URL used in samples/sample.html
|
# Now check the URL used in samples/sample.html
|
||||||
resp = httpx.get("https://upload.wikimedia.org/wikipedia/en/f/f7/RickRoll.png")
|
resp = httpx.get(
|
||||||
|
"https://upload.wikimedia.org/wikipedia/en/f/f7/RickRoll.png",
|
||||||
|
headers=self._WIKIMEDIA_HEADERS,
|
||||||
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue