-c shortcut for --config - refs #2143, #2149

pull/2151/merge
Simon Willison 2023-08-22 19:33:26 -07:00
rodzic 17ec309e14
commit 2ce7872e3b
2 zmienionych plików z 25 dodań i 0 usunięć

Wyświetl plik

@ -415,6 +415,7 @@ def uninstall(packages, yes):
)
@click.option("--memory", is_flag=True, help="Make /_memory database available")
@click.option(
"-c",
"--config",
type=click.File(mode="r"),
help="Path to JSON/YAML Datasette configuration file",

Wyświetl plik

@ -283,6 +283,30 @@ def test_serve_create(tmpdir):
assert db_path.exists()
@pytest.mark.parametrize("argument", ("-c", "--config"))
@pytest.mark.parametrize("format_", ("json", "yaml"))
def test_serve_config(tmpdir, argument, format_):
config_path = tmpdir / "datasette.{}".format(format_)
config_path.write_text(
"settings:\n default_page_size: 5\n"
if format_ == "yaml"
else '{"settings": {"default_page_size": 5}}',
"utf-8",
)
runner = CliRunner()
result = runner.invoke(
cli,
[
argument,
str(config_path),
"--get",
"/-/settings.json",
],
)
assert result.exit_code == 0, result.output
assert json.loads(result.output)["default_page_size"] == 5
def test_serve_duplicate_database_names(tmpdir):
"'datasette db.db nested/db.db' should attach two databases, /db and /db_2"
runner = CliRunner()