kopia lustrzana https://github.com/simonw/datasette
Allow "." in database filenames, closes #302
rodzic
97ae66ccab
commit
120f20cd97
|
@ -455,10 +455,10 @@ class Datasette:
|
|||
"/-/config<as_format:(\.json)?$>",
|
||||
)
|
||||
app.add_route(
|
||||
DatabaseView.as_view(self), "/<db_name:[^/\.]+?><as_format:(\.jsono?|\.csv)?$>"
|
||||
DatabaseDownload.as_view(self), "/<db_name:[^/]+?><as_db:(\.db)$>"
|
||||
)
|
||||
app.add_route(
|
||||
DatabaseDownload.as_view(self), "/<db_name:[^/]+?><as_db:(\.db)$>"
|
||||
DatabaseView.as_view(self), "/<db_name:[^/]+?><as_format:(\.jsono?|\.csv)?$>"
|
||||
)
|
||||
app.add_route(
|
||||
TableView.as_view(self),
|
||||
|
|
|
@ -24,9 +24,9 @@ class TestClient:
|
|||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
|
||||
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None, filename="fixtures.db"):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
filepath = os.path.join(tmpdir, 'fixtures.db')
|
||||
filepath = os.path.join(tmpdir, filename)
|
||||
conn = sqlite3.connect(filepath)
|
||||
conn.executescript(TABLES)
|
||||
os.chdir(os.path.dirname(filepath))
|
||||
|
@ -78,6 +78,11 @@ def app_client_csv_max_mb_one():
|
|||
})
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_client_with_dot():
|
||||
yield from app_client(filename="fixtures.dot.db")
|
||||
|
||||
|
||||
def generate_compound_rows(num):
|
||||
for a, b, c in itertools.islice(
|
||||
itertools.product(string.ascii_lowercase, repeat=3), num
|
||||
|
|
|
@ -3,6 +3,7 @@ from .fixtures import ( # noqa
|
|||
app_client_shorter_time_limit,
|
||||
app_client_larger_cache_size,
|
||||
app_client_returned_rows_matches_page_size,
|
||||
app_client_with_dot,
|
||||
generate_compound_rows,
|
||||
generate_sortable_rows,
|
||||
METADATA,
|
||||
|
@ -356,6 +357,11 @@ def test_database_page(app_client):
|
|||
}] == data['tables']
|
||||
|
||||
|
||||
def test_database_page_for_database_with_dot_in_name(app_client_with_dot):
|
||||
response = app_client_with_dot.get("/fixtures.dot.json")
|
||||
assert 200 == response.status
|
||||
|
||||
|
||||
def test_custom_sql(app_client):
|
||||
response = app_client.get(
|
||||
'/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects'
|
||||
|
|
Ładowanie…
Reference in New Issue