def test_clear_When_cache_cleared_Then_file_no_longer_in_cache(self): # Setup - create file and place in cache fileUrl = self.createSomeFile() cache = FileCache(self.cacheRootDir, FileSystemResolver()) cache.get(fileUrl) self.assertTrue(cache.contains(fileUrl)) try: # Test cache.clear() # Verify self.assertFalse(cache.contains(fileUrl)) finally: os.remove(fileUrl)
def test_get_When_file_in_cache_Then_return_filepath(self): # Setup - create file and place in cache fileUrl = self.createSomeFile() resolver = FileSystemResolver() digest = resolver.hash(fileUrl) resolver.store(fileUrl, os.path.join(self.cacheRootDir, digest)) cache = FileCache(self.cacheRootDir, resolver) try: # Test filePath = cache.get(fileUrl) # Verify - request for cached file should not pass through to resolver self.assertEquals(os.path.join(self.cacheRootDir, digest), filePath) finally: os.remove(fileUrl)