Hide 'view and edit SQL' if config.allow_sql turned off

This commit is contained in:
Simon Willison 2018-08-05 20:17:17 -07:00
commit fe5b6ea95a
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
2 changed files with 10 additions and 1 deletions

View file

@ -713,6 +713,10 @@ def test_allow_sql_on(app_client):
)
soup = Soup(response.body, 'html.parser')
assert len(soup.findAll('textarea', {'name': 'sql'}))
response = app_client.get(
"/fixtures/sortable"
)
assert b"View and edit SQL" in response.body
def test_allow_sql_off():
@ -724,6 +728,11 @@ def test_allow_sql_off():
)
soup = Soup(response.body, 'html.parser')
assert not len(soup.findAll('textarea', {'name': 'sql'}))
# The table page should no longer show "View and edit SQL"
response = client.get(
"/fixtures/sortable"
)
assert b"View and edit SQL" not in response.body
def assert_querystring_equal(expected, actual):