def topic(self): conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, STORAGE_EXPIRATION_SECONDS=5000) server = get_server('ACME-SEC') storage = MongoStorage(Context(server=server, config=conf)) storage.put(IMAGE_URL % 8, IMAGE_BYTES) return storage.get(IMAGE_URL % 8)
def test_before_expiration_returns_something(self): rm_storage() options.STORAGE_EXPIRATION_SECONDS = 1000 image_url = 'www.globo.com/media/globocom/img/sprite1.png' http_loaded = http.load(image_url) storage = Storage() storage.put(image_url, http_loaded) assert storage.get(image_url)
def topic(self): conf = Config( MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, STORAGE_EXPIRATION_SECONDS=5000 ) server = get_server('ACME-SEC') storage = MongoStorage(Context(server=server, config=conf)) storage.put(IMAGE_URL % 8, IMAGE_BYTES) return storage.get(IMAGE_URL % 8)
def test_after_expiration_returns_none(self): rm_storage() options.STORAGE_EXPIRATION_SECONDS = 1 image_url = 'www.globo.com/media/globocom/img/sprite1.png' 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 topic(self): config = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, SECURITY_KEY='ACME-SEC', STORAGE_EXPIRATION_SECONDS=0) storage = MongoStorage(Context(config=config)) storage.put(IMAGE_URL % 10, IMAGE_BYTES) item = storage.get(IMAGE_URL % 10) return item is None
def test_gets_image(self): rm_storage() options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False image_url = 'www.globo.com/media/globocom/img/sprite1.png' 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'
def topic(self): config = Config( MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, SECURITY_KEY='ACME-SEC', STORAGE_EXPIRATION_SECONDS=0 ) server = get_server('ACME-SEC') storage = MongoStorage(Context(server=server, config=config)) storage.put(IMAGE_URL % 10, IMAGE_BYTES) item = storage.get(IMAGE_URL % 10) return item is None
def test_gets_image(self): rm_storage() options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False image_url = 'www.globo.com/media/globocom/img/sprite1.png' 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'
def topic(self): storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777))) return storage.get(IMAGE_URL % 99)
def topic(self): storage = MongoStorage( Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777))) storage.put(IMAGE_URL % 2, IMAGE_BYTES) return storage.get(IMAGE_URL % 2)