diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-22 17:29:38 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-22 17:57:22 -0500 |
commit | 4e1697f5fc6065fd6bc6b60f5f3b5f3ab8a98527 (patch) | |
tree | c62e6a01635ac65d36464579fb248a25cc49b2c1 /tests | |
parent | 1a4468abb249ec3ea2c1a774bd14fded14e28d69 (diff) | |
download | requests-cache-4e1697f5fc6065fd6bc6b60f5f3b5f3ab8a98527.tar.gz |
Add SQLiteDict.size() method to estimate the database size
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/test_sqlite.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/integration/test_sqlite.py b/tests/integration/test_sqlite.py index b696236..54b0ceb 100644 --- a/tests/integration/test_sqlite.py +++ b/tests/integration/test_sqlite.py @@ -219,12 +219,19 @@ class TestSQLiteDict(BaseStorageTest): assert prev_item is None or prev_item.expires < item.expires assert item.status_code % 2 == 0 - def test_filesize(self): - """Test approximate expected size of database file, in bytes""" - cache = self.init_cache() + @pytest.mark.parametrize( + 'db_path, use_temp', + [ + ('filesize_test', True), + (':memory:', False), + ], + ) + def test_size(self, db_path, use_temp): + """Test approximate expected size of a database, for both file-based and in-memory databases""" + cache = self.init_cache(db_path, use_temp=use_temp) for i in range(100): cache[f'key_{i}'] = f'value_{i}' - assert 50000 < cache.filesize() < 200000 + assert 10000 < cache.size() < 200000 class TestSQLiteCache(BaseCacheTest): |