diff --git a/tests/test_tree.py b/tests/test_tree.py
index 0b42fa7..df828ad 100644
--- a/tests/test_tree.py
+++ b/tests/test_tree.py
@@ -3,11 +3,10 @@
import textwrap
from decimal import Decimal
from email.utils import format_datetime
-from http import HTTPStatus
from unittest import TestCase
-import dateutil
import requests_mock
+from dateutil.tz import tzoffset
from tests.helpers import gzip
from usp.log import create_logger
@@ -43,7 +42,7 @@ class TestSitemapTree(TestCase):
# Publication / "last modified" date
TEST_DATE_DATETIME = datetime.datetime(
year=2009, month=12, day=17, hour=12, minute=4, second=56,
- tzinfo=dateutil.tz.tzoffset(None, 7200),
+ tzinfo=tzoffset(None, 7200),
)
TEST_DATE_STR_ISO8601 = TEST_DATE_DATETIME.isoformat()
"""Test string date formatted as ISO 8601 (for XML and Atom 0.3 / 1.0 sitemaps)."""
@@ -59,8 +58,8 @@ def fallback_to_404_not_found_matcher(request):
"""Reply with "404 Not Found" to unmatched URLs instead of throwing NoMockAddress."""
return requests_mock.create_response(
request,
- status_code=HTTPStatus.NOT_FOUND.value,
- reason=HTTPStatus.NOT_FOUND.phrase,
+ status_code=404,
+ reason='Not Found',
headers={'Content-Type': 'text/html'},
text="
404 Not Found!
",
)
@@ -276,8 +275,8 @@ def test_sitemap_tree_for_homepage(self):
# Nonexistent sitemap
m.get(
self.TEST_BASE_URL + '/sitemap_news_missing.xml',
- status_code=HTTPStatus.NOT_FOUND.value,
- reason=HTTPStatus.NOT_FOUND.phrase,
+ status_code=404,
+ reason='Not Found',
headers={'Content-Type': 'text/html'},
text="404 Not Found!
",
)
@@ -1177,8 +1176,8 @@ def test_sitemap_tree_for_homepage_no_robots_txt(self):
# Nonexistent robots.txt
m.get(
self.TEST_BASE_URL + '/robots.txt',
- status_code=HTTPStatus.NOT_FOUND.value,
- reason=HTTPStatus.NOT_FOUND.phrase,
+ status_code=404,
+ reason='Not Found',
headers={'Content-Type': 'text/html'},
text="404 Not Found!
",
)
diff --git a/usp/web_client/abstract_client.py b/usp/web_client/abstract_client.py
index 505d7ea..bcb06ef 100644
--- a/usp/web_client/abstract_client.py
+++ b/usp/web_client/abstract_client.py
@@ -7,25 +7,25 @@
RETRYABLE_HTTP_STATUS_CODES = {
# Some servers return "400 Bad Request" initially but upon retry start working again, no idea why
- HTTPStatus.BAD_REQUEST.value,
+ int(HTTPStatus.BAD_REQUEST),
# If we timed out requesting stuff, we can just try again
- HTTPStatus.REQUEST_TIMEOUT.value,
+ int(HTTPStatus.REQUEST_TIMEOUT),
# If we got rate limited, it makes sense to wait a bit
- HTTPStatus.TOO_MANY_REQUESTS.value,
+ int(HTTPStatus.TOO_MANY_REQUESTS),
# Server might be just fine on a subsequent attempt
- HTTPStatus.INTERNAL_SERVER_ERROR.value,
+ int(HTTPStatus.INTERNAL_SERVER_ERROR),
# Upstream might reappear on a retry
- HTTPStatus.BAD_GATEWAY.value,
+ int(HTTPStatus.BAD_GATEWAY),
# Service might become available again on a retry
- HTTPStatus.SERVICE_UNAVAILABLE.value,
+ int(HTTPStatus.SERVICE_UNAVAILABLE),
# Upstream might reappear on a retry
- HTTPStatus.GATEWAY_TIMEOUT.value,
+ int(HTTPStatus.GATEWAY_TIMEOUT),
# (unofficial) 509 Bandwidth Limit Exceeded (Apache Web Server/cPanel)
509,