diff options
| author | Jordan Cook <jordan.cook@pioneer.com> | 2021-04-21 20:18:02 -0500 |
|---|---|---|
| committer | Jordan Cook <jordan.cook@pioneer.com> | 2021-04-22 00:21:49 -0500 |
| commit | c29569892f3d91c3ad6686a5cb7a0a1e2d39c5ec (patch) | |
| tree | 06c00d229dd42e996fc1b02ffdf9a9c0a5a025e3 /tests/integration/test_filesystem.py | |
| parent | dc204a8d7df9c627fcfb2b098a28f2f27fbb31c8 (diff) | |
| download | requests-cache-c29569892f3d91c3ad6686a5cb7a0a1e2d39c5ec.tar.gz | |
Reorganize backend integration tests and add some more thorough tests
Diffstat (limited to 'tests/integration/test_filesystem.py')
| -rw-r--r-- | tests/integration/test_filesystem.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/tests/integration/test_filesystem.py b/tests/integration/test_filesystem.py index 72301c9..4224de0 100644 --- a/tests/integration/test_filesystem.py +++ b/tests/integration/test_filesystem.py @@ -1,32 +1,28 @@ -import pytest import unittest from os.path import isfile from shutil import rmtree from requests_cache.backends import FileDict -from tests.integration.test_backends import BaseStorageTestCase +from tests.integration.test_backends import CACHE_NAME, BaseStorageTestCase -class FilesystemTestCase(BaseStorageTestCase, unittest.TestCase): +class FileDictTestCase(BaseStorageTestCase, unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, storage_class=FileDict, picklable=True, **kwargs) def tearDown(self): - rmtree(self.NAMESPACE) + rmtree(CACHE_NAME, ignore_errors=True) - def test_set_get(self): - cache = self.storage_class(self.NAMESPACE) - cache['key'] = 'value' - assert list(cache.keys()) == ['key'] - assert list(cache.values()) == ['value'] - - with pytest.raises(KeyError): - cache[4] + def init_cache(self, index=0, **kwargs): + cache = self.storage_class(f'{CACHE_NAME}_{index}', use_temp=True, **kwargs) + cache.clear() + return cache def test_paths(self): - cache = self.storage_class(self.NAMESPACE) - for i in range(10): + cache = self.storage_class(CACHE_NAME) + for i in range(self.num_instances): cache[f'key_{i}'] = f'value_{i}' + assert len(list(cache.paths())) == self.num_instances for path in cache.paths(): assert isfile(path) |
