mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Refs #462 * inspect command now just outputs table counts * test_inspect.py is now only tests for that CLI command * Updated some relevant documentation * Removed docs for /-/inspect since that is about to change
28 lines
964 B
Python
28 lines
964 B
Python
from .fixtures import app_client
|
|
from datasette.cli import cli
|
|
from click.testing import CliRunner
|
|
import json
|
|
|
|
|
|
def test_inspect_cli(app_client):
|
|
runner = CliRunner()
|
|
result = runner.invoke(cli, ["inspect", "fixtures.db"])
|
|
data = json.loads(result.output)
|
|
assert ["fixtures"] == list(data.keys())
|
|
database = data["fixtures"]
|
|
assert "fixtures.db" == database["file"]
|
|
assert isinstance(database["hash"], str)
|
|
assert 64 == len(database["hash"])
|
|
for table_name, expected_count in {
|
|
"Table With Space In Name": 0,
|
|
"facetable": 15
|
|
}.items():
|
|
assert expected_count == database["tables"][table_name]["count"]
|
|
|
|
|
|
def test_inspect_cli_writes_to_file(app_client):
|
|
runner = CliRunner()
|
|
result = runner.invoke(cli, ["inspect", "fixtures.db", "--inspect-file", "foo.json"])
|
|
assert 0 == result.exit_code, result.output
|
|
data = json.load(open("foo.json"))
|
|
assert ["fixtures"] == list(data.keys())
|