Skip to content

Commit

Permalink
Fix for --token= not working, refs #19
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 19, 2020
1 parent ecc824e commit 15655d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions datasette_publish_now/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,6 @@ def now2(
cmd.append("--prod")
if public:
cmd.append("--public")
if token:
cmd.extend(["--token", token])
run(cmd)
24 changes: 23 additions & 1 deletion tests/test_publish_now.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ def test_publish_now_public(mock_run, mock_which):
)


@mock.patch("shutil.which")
@mock.patch("datasette_publish_now.run")
def test_publish_now_token(mock_run, mock_which):
mock_which.return_value = True
mock_run.return_value = mock.Mock(0)
runner = CliRunner()
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(
cli.cli,
["publish", "now2", "test.db", "--project", "foo", "--token", "xyz"],
)
assert result.exit_code == 0
mock_run.assert_has_calls(
[
mock.call(
["now", "--confirm", "--no-clipboard", "--prod", "--token", "xyz"]
),
]
)


@pytest.fixture(scope="session")
@mock.patch("shutil.which")
@mock.patch("datasette_publish_now.run")
Expand Down Expand Up @@ -100,7 +122,7 @@ def test_publish_now_generate(generated_app_dir):
assert {"requirements.txt", "index.py", "now.json", "test.db"} == filenames


def test_publish_now_requiremens(generated_app_dir):
def test_publish_now_requirements(generated_app_dir):
requirements = set(
l.strip()
for l in open(os.path.join(generated_app_dir, "requirements.txt")).readlines()
Expand Down

0 comments on commit 15655d6

Please sign in to comment.