mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: avoid 500 errors with SQLLAB_BACKEND_PERSISTENCE (#25553)
This commit is contained in:
@@ -996,6 +996,41 @@ class TestCore(SupersetTestCase):
|
||||
|
||||
self.assertEqual(payload["label"], "Untitled Query foo")
|
||||
|
||||
def test_tabstate_update(self):
|
||||
username = "admin"
|
||||
self.login(username)
|
||||
# create a tab
|
||||
data = {
|
||||
"queryEditor": json.dumps(
|
||||
{
|
||||
"name": "Untitled Query foo",
|
||||
"dbId": 1,
|
||||
"schema": None,
|
||||
"autorun": False,
|
||||
"sql": "SELECT ...",
|
||||
"queryLimit": 1000,
|
||||
}
|
||||
)
|
||||
}
|
||||
resp = self.get_json_resp("/tabstateview/", data=data)
|
||||
tab_state_id = resp["id"]
|
||||
# update tab state with non-existing client_id
|
||||
client_id = "asdfasdf"
|
||||
data = {"sql": json.dumps("select 1"), "latest_query_id": json.dumps(client_id)}
|
||||
response = self.client.put(f"/tabstateview/{tab_state_id}", data=data)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertEqual(response.json["error"], "Bad request")
|
||||
# generate query
|
||||
db.session.add(Query(client_id=client_id, database_id=1))
|
||||
db.session.commit()
|
||||
# update tab state with a valid client_id
|
||||
response = self.client.put(f"/tabstateview/{tab_state_id}", data=data)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# nulls should be ok too
|
||||
data["latest_query_id"] = "null"
|
||||
response = self.client.put(f"/tabstateview/{tab_state_id}", data=data)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_virtual_table_explore_visibility(self):
|
||||
# test that default visibility it set to True
|
||||
database = superset.utils.database.get_example_database()
|
||||
|
||||
Reference in New Issue
Block a user