2015-01-12 21:24:37 +00:00
|
|
|
from django.test.testcases import TestCase, TransactionTestCase
|
|
|
|
|
|
|
|
|
|
from .connection import get_redis_connection
|
|
|
|
|
|
|
|
|
|
|
2020-11-23 17:54:00 +00:00
|
|
|
class DefenderTestCaseMixin:
|
2015-01-12 21:24:37 +00:00
|
|
|
"""Mixin used to provide a common tearDown method"""
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
"""cleanup django-defender cache after each test"""
|
2020-11-22 22:07:36 +00:00
|
|
|
super().tearDown()
|
2015-01-12 21:24:37 +00:00
|
|
|
get_redis_connection().flushdb()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DefenderTransactionTestCase(DefenderTestCaseMixin, TransactionTestCase):
|
|
|
|
|
"""Helper TransactionTestCase that cleans the cache after each test"""
|
2019-11-15 18:22:14 +00:00
|
|
|
|
2015-01-12 21:24:37 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DefenderTestCase(DefenderTestCaseMixin, TestCase):
|
|
|
|
|
"""Helper TestCase that cleans the cache after each test"""
|
2019-11-15 18:22:14 +00:00
|
|
|
|
2015-01-12 21:24:37 +00:00
|
|
|
pass
|