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_setup_cache_null_config(self): app = Flask(__name__) cache_config = {"CACHE_TYPE": "null"} assert isinstance(CacheManager._setup_cache(app, cache_config), Cache)
def parse_manifest_json(self) -> None: try: with open(self.manifest_file, "r") as f: # the manifest includes non-entry files we only need entries in # templates full_manifest = json.load(f) self.manifest = full_manifest.get("entrypoints", {}) except Exception: # pylint: disable=broad-except pass def get_manifest_files(self, bundle: str, asset_type: str) -> List[str]: if self.app and self.app.debug: self.parse_manifest_json() return self.manifest.get(bundle, {}).get(asset_type, []) APP_DIR = os.path.dirname(__file__) appbuilder = AppBuilder(update_perms=False) cache_manager = CacheManager() celery_app = celery.Celery() db = SQLA() _event_logger: Dict[str, Any] = {} event_logger = LocalProxy(lambda: _event_logger.get("event_logger")) feature_flag_manager = FeatureFlagManager() jinja_context_manager = JinjaContextManager() manifest_processor = UIManifestProcessor(APP_DIR) migrate = Migrate() results_backend_manager = ResultsBackendManager() security_manager = LocalProxy(lambda: appbuilder.sm) talisman = Talisman()
def test_setup_cache_null_config(self): app = Flask(__name__) cache_config = {"CACHE_TYPE": "null"} self.assertIsNone(CacheManager._setup_cache(app, cache_config))
def test_setup_cache_no_config(self): app = Flask(__name__) cache_config = None self.assertIsNone(CacheManager._setup_cache(app, cache_config))