Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(10)  |  Derive(0)  |  Import(2)

src/f/l/Flask-Limiter-0.3.1/tests/test_strategy.py   Flask-Limiter(Download)
import pymemcache.client
 
from flask.ext.limiter.limits import PER_SECOND, PER_MINUTE
from flask.ext.limiter.storage import MemoryStorage, RedisStorage, \
    MemcachedStorage
    def test_fixed_window(self):
        storage = MemoryStorage()
        limiter = FixedWindowRateLimiter(storage)
        with hiro.Timeline().freeze() as timeline:
            limit = PER_SECOND(10, 2)
    def test_fixed_window_with_elastic_expiry_in_memory(self):
        storage = MemoryStorage()
        limiter = FixedWindowElasticExpiryRateLimiter(storage)
        with hiro.Timeline().freeze() as timeline:
            limit = PER_SECOND(10, 2)
    def test_fixed_window_with_elastic_expiry_memcache(self):
        storage = MemcachedStorage('localhost', 11211)
        limiter = FixedWindowElasticExpiryRateLimiter(storage)
        limit = PER_SECOND(10, 2)
        self.assertTrue(all([limiter.hit(limit) for _ in range(0,10)]))
    def test_fixed_window_with_elastic_expiry_memcache_concurrency(self):
        storage = MemcachedStorage('localhost', 11211)
        limiter = FixedWindowElasticExpiryRateLimiter(storage)
        limit = PER_SECOND(100, 2)
        def _c():

src/f/l/Flask-Limiter-0.3.1/tests/test_storage.py   Flask-Limiter(Download)
from flask.ext.limiter.util import get_dependency, storage_from_string
from flask.ext.limiter.errors import ConfigurationError
from flask.ext.limiter.limits import PER_MINUTE, PER_SECOND
from flask.ext.limiter.storage import MemoryStorage, RedisStorage, MemcachedStorage
 
            timeline.forward(60)
            # touch another key and yield
            limiter.hit(PER_SECOND(1))
            time.sleep(0.1)
            self.assertTrue(per_min.key_for() not in storage.storage)
 
    def test_redis(self):
        storage = RedisStorage("redis://localhost:6379")
        limiter = FixedWindowRateLimiter(storage)
        per_min = PER_SECOND(10)
    def test_memcached(self):
        storage = MemcachedStorage("localhost", 11211)
        limiter = FixedWindowRateLimiter(storage)
        per_min = PER_SECOND(10)
        start = time.time()
    def test_large_dataset_redis_moving_window_expiry(self):
        storage = RedisStorage("redis://localhost:6379")
        limiter = MovingWindowRateLimiter(storage)
        limit = PER_SECOND(1000)
        # 100 routes