Canned query writes support JSON POST body, refs #880

This commit is contained in:
Simon Willison 2020-09-14 13:18:15 -07:00
commit 896fce228f
3 changed files with 31 additions and 5 deletions

View file

@ -1,4 +1,5 @@
from bs4 import BeautifulSoup as Soup
import json
import pytest
import re
from .fixtures import make_app_client, app_client
@ -163,6 +164,16 @@ def test_vary_header(canned_write_client):
assert "Cookie" == canned_write_client.get("/data/update_name").headers["vary"]
def test_json_post_body(canned_write_client):
response = canned_write_client.post(
"/data/add_name",
body=json.dumps({"name": "Hello"}),
allow_redirects=False,
)
assert 302 == response.status
assert "/data/add_name?success" == response.headers["Location"]
def test_canned_query_permissions_on_database_page(canned_write_client):
# Without auth only shows three queries
query_names = {