perf: Implement model specific lookups by id to improve performance (#20974)

* Implement model specific lookups by id to improve performance

* Address comments e.g. better variable names and test cleanup

* commit after cleanup

* even better name and test cleanup via rollback

Co-authored-by: Bogdan Kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
Bogdan
2022-08-09 09:59:31 -07:00
committed by GitHub
parent 6650076228
commit 17b58037f8
10 changed files with 192 additions and 11 deletions

View File

@@ -126,7 +126,7 @@ def test_post_access_denied(
"form_data": INITIAL_FORM_DATA,
}
resp = test_client.post("api/v1/explore/form_data", json=payload)
assert resp.status_code == 404
assert resp.status_code == 403
def test_post_same_key_for_same_context(
@@ -337,7 +337,7 @@ def test_put_access_denied(test_client, login_as, chart_id: int, datasource: Sql
"form_data": UPDATED_FORM_DATA,
}
resp = test_client.put(f"api/v1/explore/form_data/{KEY}", json=payload)
assert resp.status_code == 404
assert resp.status_code == 403
def test_put_not_owner(test_client, login_as, chart_id: int, datasource: SqlaTable):
@@ -349,7 +349,7 @@ def test_put_not_owner(test_client, login_as, chart_id: int, datasource: SqlaTab
"form_data": UPDATED_FORM_DATA,
}
resp = test_client.put(f"api/v1/explore/form_data/{KEY}", json=payload)
assert resp.status_code == 404
assert resp.status_code == 403
def test_get_key_not_found(test_client, login_as_admin):
@@ -367,7 +367,7 @@ def test_get(test_client, login_as_admin):
def test_get_access_denied(test_client, login_as):
login_as("gamma")
resp = test_client.get(f"api/v1/explore/form_data/{KEY}")
assert resp.status_code == 404
assert resp.status_code == 403
@patch("superset.security.SupersetSecurityManager.can_access_datasource")
@@ -387,7 +387,7 @@ def test_delete(test_client, login_as_admin):
def test_delete_access_denied(test_client, login_as):
login_as("gamma")
resp = test_client.delete(f"api/v1/explore/form_data/{KEY}")
assert resp.status_code == 404
assert resp.status_code == 403
def test_delete_not_owner(

View File

@@ -84,7 +84,7 @@ def test_post(
def test_post_access_denied(test_client, login_as, form_data):
login_as("gamma")
resp = test_client.post(f"api/v1/explore/permalink", json={"formData": form_data})
assert resp.status_code == 404
assert resp.status_code == 403
def test_get_missing_chart(