Esempio n. 1
0
 def test_resource_from_cache_without_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     traced_cache = Cache(app, config={"CACHE_TYPE": "redis"})
     # expect only the resource name
     expected_resource = "get"
     resource = _resource_from_cache_prefix("GET", traced_cache.config)
     assert resource == expected_resource
Esempio n. 2
0
 def test_resource_from_cache_without_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     config = {
         "CACHE_REDIS_PORT": REDIS_CONFIG['port'],
         "CACHE_TYPE": "redis",
     }
     traced_cache = Cache(app, config={"CACHE_TYPE": "redis"})
     # expect only the resource name
     expected_resource = "get"
     resource = _resource_from_cache_prefix("GET", traced_cache.config)
     eq_(resource, expected_resource)
Esempio n. 3
0
 def test_resource_from_cache_without_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     config = {
         "CACHE_REDIS_PORT": REDIS_CONFIG['port'],
         "CACHE_TYPE": "redis",
     }
     traced_cache = Cache(app, config={"CACHE_TYPE": "redis"})
     # expect only the resource name
     expected_resource = "get"
     resource = _resource_from_cache_prefix("GET", traced_cache.config)
     eq_(resource, expected_resource)
Esempio n. 4
0
 def test_resource_from_cache_with_empty_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     config = {
         "CACHE_TYPE": "redis",
         "CACHE_REDIS_PORT": REDIS_CONFIG['port'],
         "CACHE_KEY_PREFIX": "",
     }
     traced_cache = Cache(app, config=config)
     # expect a resource with a prefix
     expected_resource = "get"
     resource = _resource_from_cache_prefix("GET", traced_cache.cache)
     assert resource == expected_resource
Esempio n. 5
0
 def test_resource_from_cache_with_empty_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     config = {
         'CACHE_TYPE': 'redis',
         'CACHE_REDIS_PORT': REDIS_CONFIG['port'],
         'CACHE_KEY_PREFIX': '',
     }
     traced_cache = Cache(app, config=config)
     # expect a resource with a prefix
     expected_resource = 'get'
     resource = _resource_from_cache_prefix('GET', traced_cache.cache)
     assert resource == expected_resource
Esempio n. 6
0
 def test_resource_from_cache_with_prefix(self):
     # create the TracedCache instance for a Flask app
     tracer = Tracer()
     Cache = get_traced_cache(tracer, service=self.SERVICE)
     app = Flask(__name__)
     config = {
         "CACHE_TYPE": "redis",
         "CACHE_REDIS_PORT": REDIS_CONFIG['port'],
         "CACHE_KEY_PREFIX": "users",
     }
     traced_cache = Cache(app, config=config)
     # expect a resource with a prefix
     expected_resource = "get users"
     resource = _resource_from_cache_prefix("GET", traced_cache.cache)
     eq_(resource, expected_resource)