How to use the datasette.cli function in datasette

To help you get started, we’ve selected a few datasette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simonw / datasette / tests / test_publish_heroku.py View on Github external
def test_publish_heroku_installs_plugin(mock_call, mock_check_output, mock_which):
    mock_which.return_value = True
    mock_check_output.side_effect = lambda s: {"['heroku', 'plugins']": b""}[repr(s)]
    runner = CliRunner()
    with runner.isolated_filesystem():
        open("t.db", "w").write("data")
        result = runner.invoke(cli.cli, ["publish", "heroku", "t.db"], input="y\n")
        assert 0 != result.exit_code
    mock_check_output.assert_has_calls(
        [mock.call(["heroku", "plugins"]), mock.call(["heroku", "apps:list", "--json"])]
    )
    mock_call.assert_has_calls(
        [mock.call(["heroku", "plugins:install", "heroku-builds"])]
    )
github simonw / datasette / tests / test_publish_now.py View on Github external
def test_publish_now_requires_now(mock_which):
    mock_which.return_value = False
    runner = CliRunner()
    with runner.isolated_filesystem():
        open("test.db", "w").write("data")
        result = runner.invoke(cli.cli, ["publish", "nowv1", "test.db"])
        assert result.exit_code == 1
        assert "Publishing to Zeit Now requires now" in result.output
github simonw / datasette / tests / test_publish_heroku.py View on Github external
def test_publish_heroku_requires_heroku(mock_which):
    mock_which.return_value = False
    runner = CliRunner()
    with runner.isolated_filesystem():
        open("test.db", "w").write("data")
        result = runner.invoke(cli.cli, ["publish", "heroku", "test.db"])
        assert result.exit_code == 1
        assert "Publishing to Heroku requires heroku" in result.output
github simonw / datasette / tests / test_publish_cloudrun.py View on Github external
def test_publish_cloudrun_requires_gcloud(mock_which):
    mock_which.return_value = False
    runner = CliRunner()
    with runner.isolated_filesystem():
        open("test.db", "w").write("data")
        result = runner.invoke(cli.cli, ["publish", "cloudrun", "test.db"])
        assert result.exit_code == 1
        assert "Publishing to Google Cloud requires gcloud" in result.output
github simonw / datasette / tests / test_publish_cloudrun.py View on Github external
def test_publish_cloudrun(mock_call, mock_output, mock_which):
    mock_output.return_value = "myproject"
    mock_which.return_value = True
    runner = CliRunner()
    with runner.isolated_filesystem():
        open("test.db", "w").write("data")
        result = runner.invoke(cli.cli, ["publish", "cloudrun", "test.db"])
        assert 0 == result.exit_code
        tag = "gcr.io/{}/datasette".format(mock_output.return_value)
        mock_call.assert_has_calls(
            [
                mock.call("gcloud builds submit --tag {}".format(tag), shell=True),
                mock.call(
                    "gcloud beta run deploy --allow-unauthenticated --image {}".format(
                        tag
                    ),
                    shell=True,
                ),
github simonw / datasette / tests / test_publish_now.py View on Github external
def test_publish_now_using_now_alias(mock_which):
    mock_which.return_value = True
    result = CliRunner().invoke(cli.cli, ["publish", "now", "woop.db"])
    assert result.exit_code == 2