Skip to content

Commit

Permalink
Publish with cors=True, closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed May 7, 2020
1 parent 8a0cf9f commit ff85913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datasette_publish_now/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
except Exception:
pass
app = Datasette([], {database_files}, metadata=metadata{extras}).app()
app = Datasette([], {database_files}, metadata=metadata{extras}, cors=True).app()
""".strip()

project_name_re = re.compile(r"^[a-z0-9][a-z0-9-]{1,51}$")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_publish_now.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
import re
import subprocess
import textwrap


@mock.patch("shutil.which")
Expand Down Expand Up @@ -120,6 +121,20 @@ def test_publish_now_generate(generated_app_dir):
# Test that the correct files were generated
filenames = set(os.listdir(generated_app_dir))
assert {"requirements.txt", "index.py", "now.json", "test.db"} == filenames
index_py = open(os.path.join(generated_app_dir, "index.py")).read()
assert textwrap.dedent("""
from datasette.app import Datasette
import json
metadata = dict()
try:
metadata = json.load(open("metadata.json"))
except Exception:
pass
app = Datasette([], ["test.db"], metadata=metadata, cors=True).app()
""").strip() == index_py.strip()


def test_publish_now_requirements(generated_app_dir):
Expand Down

0 comments on commit ff85913

Please sign in to comment.