e52ddb7dd4
CodeQL / Analyze (python) (push) Failing after 1s
Linting and testing / build (3.11) (push) Failing after 0s
Package exe with PyInstaller - Windows / build (push) Failing after 2s
Linting and testing / build (3.10) (push) Failing after 1s
Linting and testing / minimal-install (push) Failing after 1s
Update sites rating and statistics / build (push) Failing after 1s
Build docker image and push to DockerHub / docker (push) Failing after 1s
Linting and testing / build (3.12) (push) Failing after 1s
Linting and testing / build (3.14) (push) Failing after 1s
Linting and testing / build (3.13) (push) Failing after 2s
39 lines
846 B
Python
39 lines
846 B
Python
"""
|
|
Unit tests for error page detection helpers.
|
|
"""
|
|
|
|
from maigret.error_detection import detect_error_page
|
|
from maigret.errors import CheckError
|
|
|
|
|
|
def test_site_specific_error():
|
|
err = detect_error_page(
|
|
"this page is blocked",
|
|
200,
|
|
{"blocked": "Blocked by site"},
|
|
ignore_403=False,
|
|
)
|
|
|
|
assert isinstance(err, CheckError)
|
|
assert err.type == "Site-specific"
|
|
|
|
|
|
def test_http_403():
|
|
err = detect_error_page("x", 403, {}, ignore_403=False)
|
|
|
|
assert err.type == "Access denied"
|
|
|
|
|
|
def test_http_500():
|
|
err = detect_error_page("x", 500, {}, ignore_403=False)
|
|
|
|
assert err.type == "Server"
|
|
|
|
|
|
def test_no_error():
|
|
assert detect_error_page("ok", 200, {}, ignore_403=False) is None
|
|
|
|
|
|
def test_ignore_linkedin_999_status():
|
|
assert detect_error_page("", 999, {}, ignore_403=False) is None
|