def test_cache_full(config_stub, tmpdir):
 config_stub.data = {'storage': {'cache-size': 1024}, 'general': {'private-browsing': False}}
 disk_cache = QNetworkDiskCache()
 disk_cache.setCacheDirectory(str(tmpdir))
 url = 'http://qutebrowser.org'
 content = 'cutebowser'
 preload_cache(disk_cache, url, content)
 url2 = 'https://qutebrowser.org'
 content2 = 'ohmycert'
 preload_cache(disk_cache, url2, content2)
 metadata = QNetworkCacheMetaData()
 metadata.setUrl(QUrl(url))
 soon = QDateTime.currentDateTime().addMonths(4)
 assert soon.isValid()
 metadata.setLastModified(soon)
 assert metadata.isValid()
 disk_cache.updateMetaData(metadata)
 disk_cache.remove(QUrl(url2))
 assert (disk_cache.metaData(QUrl(url)).lastModified() == soon)
 assert (disk_cache.data(QUrl(url)).readAll() == content)

def test_cache_full ( config_stub , tmpdir ) : config_stub . data = { 'storage' : { 'cache-size' : 1024 } , 'general' : { 'private-browsing' : False } } disk_cache = QNetworkDiskCache ( ) disk_cache . setCacheDirectory ( str ( tmpdir ) ) url = 'http://qutebrowser.org' content = 'cutebowser' preload_cache ( disk_cache , url , content ) url2 = 'https://qutebrowser.org' content2 = 'ohmycert' preload_cache ( disk_cache , url2 , content2 ) metadata = QNetworkCacheMetaData ( ) metadata . setUrl ( QUrl ( url ) ) soon = QDateTime . currentDateTime ( ) . addMonths ( 4 ) assert soon . isValid ( ) metadata . setLastModified ( soon ) assert metadata . isValid ( ) disk_cache . updateMetaData ( metadata ) disk_cache . remove ( QUrl ( url2 ) ) assert ( disk_cache . metaData ( QUrl ( url ) ) . lastModified ( ) == soon ) assert ( disk_cache . data ( QUrl ( url ) ) . readAll ( ) == content )
do a sanity test involving everything .