Add another test for pyqtslot on_config_changed
There are now two tests changing the config for private-browsing, covering both True->False and False->True.
This commit is contained in:
parent
70a6fe1561
commit
e86795f644
@ -50,17 +50,15 @@ def test_cache_config_change_cache_size(config_stub, tmpdir):
|
||||
assert disk_cache.maximumCacheSize() == max_cache_size * 2
|
||||
|
||||
|
||||
def test_cache_config_change_private_browsing(config_stub, tmpdir):
|
||||
"""Change private-browsing config and emit signal."""
|
||||
def test_cache_config_enable_private_browsing(config_stub, tmpdir):
|
||||
"""Change private-browsing config to True and emit signal."""
|
||||
config_stub.data = {
|
||||
'storage': {'cache-size': 1024},
|
||||
'general': {'private-browsing': False}
|
||||
}
|
||||
url = 'http://qutebrowser.org'
|
||||
content = b'cute'
|
||||
disk_cache = cache.DiskCache(str(tmpdir))
|
||||
assert disk_cache.cacheSize() == 0
|
||||
preload_cache(disk_cache, url, content)
|
||||
preload_cache(disk_cache)
|
||||
assert disk_cache.cacheSize() > 0
|
||||
|
||||
config_stub.data['general']['private-browsing'] = True
|
||||
@ -68,6 +66,27 @@ def test_cache_config_change_private_browsing(config_stub, tmpdir):
|
||||
assert disk_cache.cacheSize() == 0
|
||||
|
||||
|
||||
def test_cache_config_disable_private_browsing(config_stub, tmpdir):
|
||||
"""Change private-browsing config to False and emit signal."""
|
||||
config_stub.data = {
|
||||
'storage': {'cache-size': 1024},
|
||||
'general': {'private-browsing': True}
|
||||
}
|
||||
url = 'http://qutebrowser.org'
|
||||
metadata = QNetworkCacheMetaData()
|
||||
metadata.setUrl(QUrl(url))
|
||||
assert metadata.isValid()
|
||||
|
||||
disk_cache = cache.DiskCache(str(tmpdir))
|
||||
assert disk_cache.prepare(metadata) is None
|
||||
|
||||
config_stub.data['general']['private-browsing'] = False
|
||||
config_stub.changed.emit('general', 'private-browsing')
|
||||
content = b'cute'
|
||||
preload_cache(disk_cache, url, content)
|
||||
assert disk_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
|
||||
|
Loading…
Reference in New Issue
Block a user