mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore: Using cache factory method (#10887)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -27,7 +27,6 @@ from unittest.mock import Mock, patch
|
||||
|
||||
import numpy
|
||||
from flask import Flask, g
|
||||
from flask_caching import Cache
|
||||
import marshmallow
|
||||
from sqlalchemy.exc import ArgumentError
|
||||
|
||||
@@ -37,7 +36,6 @@ from superset.exceptions import CertificateException, SupersetException
|
||||
from superset.models.core import Database, Log
|
||||
from superset.models.dashboard import Dashboard
|
||||
from superset.models.slice import Slice
|
||||
from superset.utils.cache_manager import CacheManager
|
||||
from superset.utils.core import (
|
||||
base_json_conv,
|
||||
cast_to_num,
|
||||
@@ -834,32 +832,6 @@ class TestUtils(SupersetTestCase):
|
||||
self.assertIsNone(parse_js_uri_path_item(None))
|
||||
self.assertIsNotNone(parse_js_uri_path_item("item"))
|
||||
|
||||
def test_setup_cache_null_config(self):
|
||||
app = Flask(__name__)
|
||||
cache_config = {"CACHE_TYPE": "null"}
|
||||
assert isinstance(CacheManager._setup_cache(app, cache_config), Cache)
|
||||
|
||||
def test_setup_cache_standard_config(self):
|
||||
app = Flask(__name__)
|
||||
cache_config = {
|
||||
"CACHE_TYPE": "redis",
|
||||
"CACHE_DEFAULT_TIMEOUT": 60,
|
||||
"CACHE_KEY_PREFIX": "superset_results",
|
||||
"CACHE_REDIS_URL": "redis://localhost:6379/0",
|
||||
}
|
||||
assert isinstance(CacheManager._setup_cache(app, cache_config), Cache) is True
|
||||
|
||||
def test_setup_cache_custom_function(self):
|
||||
app = Flask(__name__)
|
||||
CustomCache = type("CustomCache", (object,), {"__init__": lambda *args: None})
|
||||
|
||||
def init_cache(app):
|
||||
return CustomCache(app, {})
|
||||
|
||||
assert (
|
||||
isinstance(CacheManager._setup_cache(app, init_cache), CustomCache) is True
|
||||
)
|
||||
|
||||
def test_get_stacktrace(self):
|
||||
with app.app_context():
|
||||
app.config["SHOW_STACKTRACE"] = True
|
||||
|
||||
Reference in New Issue
Block a user