diff options
author | Lamar Pavel <lamarpavel@sigaint.org> | 2015-10-29 02:37:32 +0100 |
---|---|---|
committer | Lamar Pavel <lamarpavel@sigaint.org> | 2015-10-29 02:37:32 +0100 |
commit | 2cab750a54a32bfdc7632a4bcb84f0d9f3cd1880 (patch) | |
tree | 5f28f628c8dbcdd6a326f371d98380a5454c670d /tests | |
parent | e4c79a68d1491aea5028d9b94d93d6bcb4e862a2 (diff) | |
download | qutebrowser-2cab750a54a32bfdc7632a4bcb84f0d9f3cd1880.tar.gz qutebrowser-2cab750a54a32bfdc7632a4bcb84f0d9f3cd1880.zip |
Add test for DiskCache.remove()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/browser/test_cache.py | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/tests/unit/browser/test_cache.py b/tests/unit/browser/test_cache.py index 83a8fc035..8090f48e3 100644 --- a/tests/unit/browser/test_cache.py +++ b/tests/unit/browser/test_cache.py @@ -35,20 +35,6 @@ def preload_cache(cache, url='http://www.example.com/', content=b'foobar'): cache.insert(device) -def test_cache_insert_data(tmpdir): - """Test if entries inserted into the cache are actually there.""" - URL = 'http://qutebrowser.org' - CONTENT = b'foobar' - cache = QNetworkDiskCache() - cache.setCacheDirectory(str(tmpdir)) - assert cache.cacheSize() == 0 - - preload_cache(cache, URL, CONTENT) - - assert cache.cacheSize() != 0 - assert cache.data(QUrl(URL)).readAll() == CONTENT - - def test_cache_size_leq_max_cache_size(config_stub, tmpdir): """Test cacheSize <= MaximumCacheSize when cache is activated.""" LIMIT = 100 @@ -81,6 +67,32 @@ def test_cache_deactivated_private_browsing(config_stub, tmpdir): assert disk_cache.prepare(metadata) is None +def test_cache_insert_data(tmpdir): + """Test if entries inserted into the cache are actually there.""" + URL = 'http://qutebrowser.org' + CONTENT = b'foobar' + disk_cache = QNetworkDiskCache() + disk_cache.setCacheDirectory(str(tmpdir)) + assert disk_cache.cacheSize() == 0 + + preload_cache(disk_cache, URL, CONTENT) + + assert disk_cache.cacheSize() != 0 + assert disk_cache.data(QUrl(URL)).readAll() == CONTENT + + +def test_cache_remove_data(tmpdir): + """Test if a previously inserted entry can be removed from the cache.""" + URL = 'http://qutebrowser.org' + disk_cache = QNetworkDiskCache() + disk_cache.setCacheDirectory(str(tmpdir)) + preload_cache(disk_cache, URL) + assert disk_cache.cacheSize() > 0 + + assert disk_cache.remove(QUrl(URL)) + assert disk_cache.cacheSize() == 0 + + def test_clear_cache_activated(config_stub, tmpdir): """Test if cache is empty after clearing it.""" config_stub.data = { |