From 1130feb50b2e55b622201db83d7b0977dfca60b0 Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Mon, 6 Nov 2023 16:33:46 +0100 Subject: [PATCH] factorize code --- ippisite/ippidb/tests/utils.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ippisite/ippidb/tests/utils.py b/ippisite/ippidb/tests/utils.py index 8435a793..e09bc0d9 100644 --- a/ippisite/ippidb/tests/utils.py +++ b/ippisite/ippidb/tests/utils.py @@ -66,14 +66,22 @@ def create_dummy_drugbank_compound(id_, smiles): dbc.save() +def my_install_cache(): + backend = requests_cache.SQLiteCache( + os.path.join(settings.PERSISTENT_DIR, "tests_http_cache"), + use_memory=True, + use_temp=True, + ) + requests_cache.install_cache(backend=backend) + + class TestCaseWithRequestsCache(TestCase): def setUp(self): - requests_cache.install_cache(os.path.join(settings.PERSISTENT_DIR, "tests_http_cache"), backend="sqlite") + my_install_cache() class TransactionTestCaseWithRequestsCache(TransactionTestCase): def setUp(self): - backend = requests_cache.SQLiteCache(os.path.join(settings.PERSISTENT_DIR, "tests_http_cache"), use_memory=True) - requests_cache.install_cache(backend=backend) + my_install_cache() -- GitLab