tests: verify hooks by propagating exceptions
This commit is contained in:
parent
7b92d0fe55
commit
abfaf85a43
|
@ -1,4 +1,5 @@
|
|||
import copy
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import django_webtest
|
||||
|
@ -130,3 +131,26 @@ def pdf_file():
|
|||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def redis_client(monkeypatch):
|
||||
from authentic2_cut.apps import AppConfig
|
||||
|
||||
class RedisClientMock(object):
|
||||
def __init__(self):
|
||||
self.contents = {}
|
||||
self.timeouts = {}
|
||||
|
||||
def expire(self, key, delta):
|
||||
if delta:
|
||||
self.timeouts[key] = time.time() + delta
|
||||
elif key in self.expire:
|
||||
del self.timeouts[key]
|
||||
|
||||
def incr(self, key):
|
||||
self.contents.setdefault(key, 0)
|
||||
self.contents[key] += 1
|
||||
|
||||
redis_client = RedisClientMock()
|
||||
monkeypatch.setattr(AppConfig, 'redis_client', redis_client)
|
||||
yield redis_client
|
||||
|
||||
|
|
|
@ -17,3 +17,6 @@ if 'postgres' in DATABASES['default']['ENGINE']:
|
|||
LANGUAGE_CODE = 'en'
|
||||
A2_FC_CLIENT_ID = ''
|
||||
A2_FC_CLIENT_SECRET = ''
|
||||
|
||||
# test hook handlers
|
||||
A2_HOOKS_PROPAGATE_EXCEPTIONS = True
|
||||
|
|
Loading…
Reference in New Issue