Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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
Example #6
0
 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
Example #7
0
            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
Example #8
0
 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'
Example #9
0
            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
Example #10
0
 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'
Example #11
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     return storage.get(IMAGE_URL % 99)
Example #12
0
 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)