mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore: enforce more ruff rules (#31447)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9da65d6bfd
commit
e51b95ffa8
@@ -257,7 +257,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
expected_paths = {
|
||||
"metadata.yaml",
|
||||
f"dashboards/COVID_Vaccine_Dashboard_{example_dashboard.id}.yaml",
|
||||
"datasets/examples/covid_vaccines.yaml", # referenced dataset needs to be exported
|
||||
"datasets/examples/covid_vaccines.yaml", # referenced dataset needs to be exported # noqa: E501
|
||||
"databases/examples.yaml",
|
||||
}
|
||||
for chart in example_dashboard.slices:
|
||||
@@ -296,7 +296,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
)
|
||||
command = ExportDashboardsCommand([example_dashboard.id])
|
||||
contents = command.run()
|
||||
with self.assertRaises(DashboardNotFoundError):
|
||||
with self.assertRaises(DashboardNotFoundError): # noqa: PT027
|
||||
next(contents)
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@@ -308,7 +308,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
mock_g2.user = security_manager.find_user("admin")
|
||||
command = ExportDashboardsCommand([-1])
|
||||
contents = command.run()
|
||||
with self.assertRaises(DashboardNotFoundError):
|
||||
with self.assertRaises(DashboardNotFoundError): # noqa: PT027
|
||||
next(contents)
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@@ -766,7 +766,7 @@ class TestCopyDashboardCommand(SupersetTestCase):
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
def test_copy_dashboard_command_no_access(self):
|
||||
"""Test that a non-owner user cannot copy a dashboard if DASHBOARD_RBAC is enabled"""
|
||||
"""Test that a non-owner user cannot copy a dashboard if DASHBOARD_RBAC is enabled""" # noqa: E501
|
||||
with self.client.application.test_request_context():
|
||||
example_dashboard = (
|
||||
db.session.query(Dashboard).filter_by(slug="world_health").one()
|
||||
@@ -779,7 +779,7 @@ class TestCopyDashboardCommand(SupersetTestCase):
|
||||
return_value=True,
|
||||
):
|
||||
command = CopyDashboardCommand(example_dashboard, copy_data)
|
||||
with self.assertRaises(DashboardForbiddenError):
|
||||
with self.assertRaises(DashboardForbiddenError): # noqa: PT027
|
||||
command.run()
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@@ -793,7 +793,7 @@ class TestCopyDashboardCommand(SupersetTestCase):
|
||||
|
||||
with override_user(security_manager.find_user("admin")):
|
||||
command = CopyDashboardCommand(example_dashboard, invalid_copy_data)
|
||||
with self.assertRaises(DashboardInvalidError):
|
||||
with self.assertRaises(DashboardInvalidError): # noqa: PT027
|
||||
command.run()
|
||||
|
||||
|
||||
@@ -868,16 +868,16 @@ class TestFavoriteDashboardCommand(SupersetTestCase):
|
||||
example_dashboard_id = 1234
|
||||
|
||||
with override_user(security_manager.find_user("admin")):
|
||||
with self.assertRaises(DashboardNotFoundError):
|
||||
with self.assertRaises(DashboardNotFoundError): # noqa: PT027
|
||||
AddFavoriteDashboardCommand(example_dashboard_id).run()
|
||||
|
||||
with self.assertRaises(DashboardNotFoundError):
|
||||
with self.assertRaises(DashboardNotFoundError): # noqa: PT027
|
||||
DelFavoriteDashboardCommand(example_dashboard_id).run()
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@patch("superset.models.dashboard.Dashboard.get")
|
||||
def test_fave_unfave_dashboard_command_forbidden(self, mock_get):
|
||||
"""Test that faving / unfaving raises an exception for a dashboard the user doesn't own"""
|
||||
"""Test that faving / unfaving raises an exception for a dashboard the user doesn't own""" # noqa: E501
|
||||
with self.client.application.test_request_context():
|
||||
example_dashboard = (
|
||||
db.session.query(Dashboard).filter_by(slug="world_health").one()
|
||||
@@ -889,8 +889,8 @@ class TestFavoriteDashboardCommand(SupersetTestCase):
|
||||
assert example_dashboard is not None
|
||||
|
||||
with override_user(security_manager.find_user("gamma")):
|
||||
with self.assertRaises(DashboardAccessDeniedError):
|
||||
with self.assertRaises(DashboardAccessDeniedError): # noqa: PT027
|
||||
AddFavoriteDashboardCommand(example_dashboard.uuid).run()
|
||||
|
||||
with self.assertRaises(DashboardAccessDeniedError):
|
||||
with self.assertRaises(DashboardAccessDeniedError): # noqa: PT027
|
||||
DelFavoriteDashboardCommand(example_dashboard.uuid).run()
|
||||
|
||||
Reference in New Issue
Block a user