code: def test_permissions_cascade(
      cascade_app_client, path, permissions, expected_status
  ):
      """Test that e.g. having view-table but NOT view-database lets you view table page, etc"""
      allow = {"id": "*"}
      deny = {}
      previous_config = cascade_app_client.ds.config
      updated_config = copy.deepcopy(previous_config)
      actor = {"id": "test"}
      if "download" in permissions:
          actor["can_download"] = 1
      try:
          # Set up the different allow blocks
          updated_config["allow"] = (
              allow if "instance" in permissions else deny
          )
          updated_config["databases"]["fixtures"]["allow"] = (
              allow if "database" in permissions else deny
          )
          updated_config["databases"]["fixtures"]["tables"][
              "binary_data"
          ] = {"allow": (allow if "table" in permissions else deny)}
          updated_config["databases"]["fixtures"]["queries"][
              "magic_parameters"
          ]["allow"] = (allow if "query" in permissions else deny)
          cascade_app_client.ds.config = updated_config
          response = cascade_app_client.get(
              path,
              cookies={
                  "ds_actor": cascade_app_client.actor_cookie(actor)
              },
          )
          assert (
              response.status == expected_status
          ), "path: {}, permissions: {}, expected_status: {}, status: {}".format(
              path, permissions, expected_status, response.status
          )
      finally:
          cascade_app_client.ds.config = previous_config
  
imports: import collections
  from datasette.app import Datasette
  from datasette.cli import cli
  from datasette.default_permissions import restrictions_allow_action
  from .fixtures import app_client, assert_permissions_checked, make_app_client
  from click.testing import CliRunner
  from bs4 import BeautifulSoup
  import copy
  import json
  from pprint import pprint
  import pytest_asyncio
  import pytest
  import re
  import time
  import urllib
label_desc: Use image node_id 16 for calling a global function with example usage: test_permissions_cascade(cascade_app_client, path, permissions, expected_status) without return types