correct way to use fakeredis

fix #229
This commit is contained in:
Benny 2023-05-01 20:43:35 +02:00
parent f2b47fb392
commit 3e759615a4
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481
2 changed files with 4 additions and 3 deletions

View file

@ -59,7 +59,7 @@ class Channel(Payment):
cookie = {"CONSENT": "YES+cb.20210328-17-p0.en+FX+999"}
# send head request first
r = requests.head(url, headers=headers, allow_redirects=True, cookies=cookie)
if r.status_code != http.HTTPStatus.METHOD_NOT_ALLOWED and "text/html" not in r.headers.get("content-type"):
if r.status_code != http.HTTPStatus.METHOD_NOT_ALLOWED and "text/html" not in r.headers.get("content-type", ""):
# get content-type, if it's not text/html, there's no need to issue a GET request
logging.warning("%s Content-type is not text/html, no need to GET for extract_canonical_link", url)
return url

View file

@ -71,9 +71,10 @@ class Cursor:
class Redis:
def __init__(self):
if REDIS:
try:
self.r = redis.StrictRedis(host=REDIS, db=0, decode_responses=True)
else:
self.r.ping()
except redis.RedisError:
self.r = fakeredis.FakeStrictRedis(host=REDIS, db=0, decode_responses=True)
db_banner = "=" * 20 + "DB data" + "=" * 20