def test_before_expiration_returns_something(self): options.STORAGE_EXPIRATION_SECONDS = 1000 image_url = 'www.globo.com/media/globocom/img/sprite1.png?8' http_loaded = http.load(image_url) storage = Storage() storage.put(image_url, http_loaded) assert storage.get(image_url)
def test_after_expiration_returns_none(self): options.STORAGE_EXPIRATION_SECONDS = 1 image_url = 'www.globo.com/media/globocom/img/sprite1.png?9' http_loaded = http.load(image_url) storage = Storage() storage.put(image_url, http_loaded) time.sleep(2) assert storage.get(image_url) is None
def test_gets_image(self): options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False image_url = 'www.globo.com/media/globocom/img/sprite1.png?2' http_loaded = http.load(image_url) storage = Storage() storage.put(image_url, http_loaded) stored_image = storage.get(image_url) assert stored_image and not isinstance(stored_image, dict), 'image not found into the storage' assert http_loaded == stored_image, 'stored image did not match the loaded one'