mirror of
https://github.com/apache/superset.git
synced 2026-05-10 18:35:40 +00:00
chore: Remove unnecessary information from response (#24056)
This commit is contained in:
committed by
Elizabeth Thompson
parent
b53325e576
commit
831cd9b030
@@ -28,6 +28,7 @@ import yaml
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from superset import app
|
||||
from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
|
||||
from superset.dao.exceptions import (
|
||||
DAOCreateFailedError,
|
||||
@@ -1294,6 +1295,107 @@ class TestDatasetApi(SupersetTestCase):
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_dataset_get_list_no_username(self):
|
||||
"""
|
||||
Dataset API: Tests that no username is returned
|
||||
"""
|
||||
if backend() == "sqlite":
|
||||
return
|
||||
|
||||
dataset = self.insert_default_dataset()
|
||||
self.login(username="admin")
|
||||
table_data = {"description": "changed_description"}
|
||||
uri = f"api/v1/dataset/{dataset.id}"
|
||||
rv = self.client.put(uri, json=table_data)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
|
||||
response = self.get_assert_metric("api/v1/dataset/", "get_list")
|
||||
res = json.loads(response.data.decode("utf-8"))["result"]
|
||||
|
||||
current_dataset = [d for d in res if d["id"] == dataset.id][0]
|
||||
self.assertEqual(current_dataset["description"], "changed_description")
|
||||
self.assertNotIn("username", current_dataset["changed_by"].keys())
|
||||
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_dataset_get_no_username(self):
|
||||
"""
|
||||
Dataset API: Tests that no username is returned
|
||||
"""
|
||||
if backend() == "sqlite":
|
||||
return
|
||||
|
||||
dataset = self.insert_default_dataset()
|
||||
self.login(username="admin")
|
||||
table_data = {"description": "changed_description"}
|
||||
uri = f"api/v1/dataset/{dataset.id}"
|
||||
rv = self.client.put(uri, json=table_data)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
|
||||
response = self.get_assert_metric(uri, "get")
|
||||
res = json.loads(response.data.decode("utf-8"))["result"]
|
||||
|
||||
self.assertEqual(res["description"], "changed_description")
|
||||
self.assertNotIn("username", res["changed_by"].keys())
|
||||
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_dataset_activity_access_enabled(self):
|
||||
"""
|
||||
Dataset API: Test ENABLE_BROAD_ACTIVITY_ACCESS = True
|
||||
"""
|
||||
if backend() == "sqlite":
|
||||
return
|
||||
|
||||
access_flag = app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]
|
||||
app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = True
|
||||
dataset = self.insert_default_dataset()
|
||||
self.login(username="admin")
|
||||
table_data = {"description": "changed_description"}
|
||||
uri = f"api/v1/dataset/{dataset.id}"
|
||||
rv = self.client.put(uri, json=table_data)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
|
||||
response = self.get_assert_metric("api/v1/dataset/", "get_list")
|
||||
res = json.loads(response.data.decode("utf-8"))["result"]
|
||||
|
||||
current_dataset = [d for d in res if d["id"] == dataset.id][0]
|
||||
self.assertEqual(current_dataset["description"], "changed_description")
|
||||
self.assertEqual(current_dataset["changed_by_url"], "/superset/profile/admin")
|
||||
|
||||
app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = access_flag
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_dataset_activity_access_disabled(self):
|
||||
"""
|
||||
Dataset API: Test ENABLE_BROAD_ACTIVITY_ACCESS = Fase
|
||||
"""
|
||||
if backend() == "sqlite":
|
||||
return
|
||||
|
||||
access_flag = app.config["ENABLE_BROAD_ACTIVITY_ACCESS"]
|
||||
app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = False
|
||||
dataset = self.insert_default_dataset()
|
||||
self.login(username="admin")
|
||||
table_data = {"description": "changed_description"}
|
||||
uri = f"api/v1/dataset/{dataset.id}"
|
||||
rv = self.put_assert_metric(uri, table_data, "put")
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
|
||||
response = self.get_assert_metric("api/v1/dataset/", "get_list")
|
||||
res = json.loads(response.data.decode("utf-8"))["result"]
|
||||
|
||||
current_dataset = [d for d in res if d["id"] == dataset.id][0]
|
||||
self.assertEqual(current_dataset["description"], "changed_description")
|
||||
self.assertEqual(current_dataset["changed_by_url"], "")
|
||||
|
||||
app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = access_flag
|
||||
db.session.delete(dataset)
|
||||
db.session.commit()
|
||||
|
||||
def test_update_dataset_item_not_owned(self):
|
||||
"""
|
||||
Dataset API: Test update dataset item not owned
|
||||
|
||||
Reference in New Issue
Block a user