summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2021-04-22 20:49:24 -0500
committerJordan Cook <jordan.cook@pioneer.com>2021-04-22 20:55:23 -0500
commit2698d5ebb81f7639ae1f2e60b80e7d4ab5d6eff4 (patch)
tree4d323683d00a3d83364ce9d9b1cf460cd3b0b247 /tests/integration
parentca49461153ee321b757fb171bb9c8f22e7840e75 (diff)
parent26f41c191c69a3d97e06cfa950b8c55867b7d9eb (diff)
downloadrequests-cache-2698d5ebb81f7639ae1f2e60b80e7d4ab5d6eff4.tar.gz
Merge branch 'use-temp'
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_filesystem.py7
-rw-r--r--tests/integration/test_sqlite.py9
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/integration/test_filesystem.py b/tests/integration/test_filesystem.py
index 7c329a4..b65ea8c 100644
--- a/tests/integration/test_filesystem.py
+++ b/tests/integration/test_filesystem.py
@@ -1,5 +1,6 @@
from os.path import isfile
from shutil import rmtree
+from tempfile import gettempdir
from requests_cache.backends import FileCache, FileDict
from tests.integration.base_cache_test import BaseCacheTest
@@ -19,6 +20,12 @@ class TestFileDict(BaseStorageTest):
cache.clear()
return cache
+ def test_use_temp(self):
+ relative_path = self.storage_class(CACHE_NAME).cache_dir
+ temp_path = self.storage_class(CACHE_NAME, use_temp=True).cache_dir
+ assert not relative_path.startswith(gettempdir())
+ assert temp_path.startswith(gettempdir())
+
def test_paths(self):
cache = self.storage_class(CACHE_NAME)
for i in range(self.num_instances):
diff --git a/tests/integration/test_sqlite.py b/tests/integration/test_sqlite.py
index fd463ac..6efba0b 100644
--- a/tests/integration/test_sqlite.py
+++ b/tests/integration/test_sqlite.py
@@ -1,4 +1,5 @@
import os
+from tempfile import gettempdir
from threading import Thread
from unittest.mock import patch
@@ -8,6 +9,8 @@ from tests.integration.base_storage_test import CACHE_NAME, BaseStorageTest
class SQLiteTestCase(BaseStorageTest):
+ init_kwargs = {'use_temp': True}
+
@classmethod
def teardown_class(cls):
try:
@@ -15,6 +18,12 @@ class SQLiteTestCase(BaseStorageTest):
except Exception:
pass
+ def test_use_temp(self):
+ relative_path = self.storage_class(CACHE_NAME).db_path
+ temp_path = self.storage_class(CACHE_NAME, use_temp=True).db_path
+ assert not relative_path.startswith(gettempdir())
+ assert temp_path.startswith(gettempdir())
+
def test_bulk_commit(self):
cache = self.init_cache()
with cache.bulk_commit():