code: def test_cli_create_token(app_client, expires):
      secret = app_client.ds._secret
      runner = CliRunner(mix_stderr=False)
      args = ["create-token", "--secret", secret, "test"]
      if expires:
          args += ["--expires-after", str(expires)]
      result = runner.invoke(cli, args)
      assert result.exit_code == 0
      token = result.output.strip()
      assert token.startswith("dstok_")
      details = app_client.ds.unsign(token[len("dstok_") :], "token")
      expected_keys = {"a", "t"}
      if expires:
          expected_keys.add("d")
      assert details.keys() == expected_keys
      assert details["a"] == "test"
      response = app_client.get(
          "/-/actor.json",
          headers={"Authorization": "Bearer {}".format(token)},
      )
      if expires is None or expires > 0:
          expected_actor = {
              "id": "test",
              "token": "dstok",
          }
          if expires and expires > 0:
              expected_actor["token_expires"] = details["t"] + expires
          assert response.json == {"actor": expected_actor}
      else:
          expected_actor = None
      assert response.json == {"actor": expected_actor}
  
file_path: datasette/tests/test_auth.py
imports: from bs4 import BeautifulSoup
  from .fixtures import app_client
  from .utils import cookie_was_deleted
  from click.testing import CliRunner
  from datasette.utils import baseconv
  from datasette.cli import cli
  import pytest
  import time
label_desc: Use image node_id 3 for calling a global function with example usage: test_cli_create_token(app_client, expires) without return types