37 lines
806 B
Python
37 lines
806 B
Python
"""Tests for spruce.download_result classification."""
|
|
|
|
import requests
|
|
|
|
from spruce.download_result import (
|
|
PERMANENT_MISSING,
|
|
TRANSIENT,
|
|
UNKNOWN,
|
|
classify_http_error,
|
|
error_code_str,
|
|
)
|
|
|
|
|
|
def test_classify_404_permanent():
|
|
assert classify_http_error(404, None) == PERMANENT_MISSING
|
|
|
|
|
|
def test_classify_410_permanent():
|
|
assert classify_http_error(410, None) == PERMANENT_MISSING
|
|
|
|
|
|
def test_classify_503_transient():
|
|
assert classify_http_error(503, None) == TRANSIENT
|
|
|
|
|
|
def test_classify_timeout_transient():
|
|
assert classify_http_error(None, requests.Timeout()) == TRANSIENT
|
|
|
|
|
|
def test_classify_unknown_4xx():
|
|
assert classify_http_error(403, None) == UNKNOWN
|
|
|
|
|
|
def test_error_code_str():
|
|
assert error_code_str(None) == ""
|
|
assert error_code_str(404) == "404"
|