def test_cache_existing_metadata_file(config_stub, tmpdir):
 config_stub.data = {'storage': {'cache-size': 1024}, 'general': {'private-browsing': False}}
 url = 'http://qutebrowser.org'
 content = 'foobar'
 metadata = QNetworkCacheMetaData()
 metadata.setUrl(QUrl(url))
 assert metadata.isValid()
 disk_cache = cache.DiskCache(str(tmpdir))
 device = disk_cache.prepare(metadata)
 assert (device is not None)
 device.write(content)
 disk_cache.insert(device)
 disk_cache.updateMetaData(metadata)
 files = list(tmpdir.visit(fil=(lambda path: path.isfile())))
 assert (len(files) == 1)
 assert (disk_cache.fileMetaData(str(files[0])) == metadata)

def test_cache_existing_metadata_file ( config_stub , tmpdir ) : config_stub . data = { 'storage' : { 'cache-size' : 1024 } , 'general' : { 'private-browsing' : False } } url = 'http://qutebrowser.org' content = 'foobar' metadata = QNetworkCacheMetaData ( ) metadata . setUrl ( QUrl ( url ) ) assert metadata . isValid ( ) disk_cache = cache . DiskCache ( str ( tmpdir ) ) device = disk_cache . prepare ( metadata ) assert ( device is not None ) device . write ( content ) disk_cache . insert ( device ) disk_cache . updateMetaData ( metadata ) files = list ( tmpdir . visit ( fil = ( lambda path : path . isfile ( ) ) ) ) assert ( len ( files ) == 1 ) assert ( disk_cache . fileMetaData ( str ( files [ 0 ] ) ) == metadata )
test querying existing meta data file from activated cache .