mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
config.json is now settings.json, closes #1104
This commit is contained in:
parent
2a3d5b720b
commit
33eadb8782
5 changed files with 30 additions and 9 deletions
|
|
@ -3,7 +3,9 @@ import pytest
|
|||
import sqlite3
|
||||
|
||||
from datasette.app import Datasette
|
||||
from datasette.cli import cli
|
||||
from .fixtures import TestClient as _TestClient
|
||||
from click.testing import CliRunner
|
||||
|
||||
PLUGIN = """
|
||||
from datasette import hookimpl
|
||||
|
|
@ -15,7 +17,7 @@ def extra_template_vars():
|
|||
}
|
||||
"""
|
||||
METADATA = {"title": "This is from metadata"}
|
||||
CONFIG = {
|
||||
SETTINGS = {
|
||||
"default_cache_ttl": 60,
|
||||
}
|
||||
CSS = """
|
||||
|
|
@ -44,7 +46,7 @@ def config_dir_client(tmp_path_factory):
|
|||
(static_dir / "hello.css").write_text(CSS, "utf-8")
|
||||
|
||||
(config_dir / "metadata.json").write_text(json.dumps(METADATA), "utf-8")
|
||||
(config_dir / "config.json").write_text(json.dumps(CONFIG), "utf-8")
|
||||
(config_dir / "settings.json").write_text(json.dumps(SETTINGS), "utf-8")
|
||||
|
||||
for dbname in ("demo.db", "immutable.db"):
|
||||
db = sqlite3.connect(str(config_dir / dbname))
|
||||
|
|
@ -85,12 +87,21 @@ def test_metadata(config_dir_client):
|
|||
assert METADATA == response.json
|
||||
|
||||
|
||||
def test_config(config_dir_client):
|
||||
def test_settings(config_dir_client):
|
||||
response = config_dir_client.get("/-/settings.json")
|
||||
assert 200 == response.status
|
||||
assert 60 == response.json["default_cache_ttl"]
|
||||
|
||||
|
||||
def test_error_on_config_json(tmp_path_factory):
|
||||
config_dir = tmp_path_factory.mktemp("config-dir")
|
||||
(config_dir / "config.json").write_text(json.dumps(SETTINGS), "utf-8")
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
result = runner.invoke(cli, [str(config_dir), "--get", "/-/settings.json"])
|
||||
assert result.exit_code == 1
|
||||
assert "config.json should be renamed to settings.json" in result.stderr
|
||||
|
||||
|
||||
def test_plugins(config_dir_client):
|
||||
response = config_dir_client.get("/-/plugins.json")
|
||||
assert 200 == response.status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue