mirror of
https://github.com/apache/superset.git
synced 2026-04-12 04:37:49 +00:00
fix: Refactor SQL username logic (#19914)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -187,7 +187,7 @@ class TestPrestoValidator(SupersetTestCase):
|
||||
"message": "your query isn't how I like it",
|
||||
}
|
||||
|
||||
@patch("superset.sql_validators.presto_db.g")
|
||||
@patch("superset.utils.core.g")
|
||||
def test_validator_success(self, flask_g):
|
||||
flask_g.user.username = "nobody"
|
||||
sql = "SELECT 1 FROM default.notarealtable"
|
||||
@@ -197,7 +197,7 @@ class TestPrestoValidator(SupersetTestCase):
|
||||
|
||||
self.assertEqual([], errors)
|
||||
|
||||
@patch("superset.sql_validators.presto_db.g")
|
||||
@patch("superset.utils.core.g")
|
||||
def test_validator_db_error(self, flask_g):
|
||||
flask_g.user.username = "nobody"
|
||||
sql = "SELECT 1 FROM default.notarealtable"
|
||||
@@ -209,7 +209,7 @@ class TestPrestoValidator(SupersetTestCase):
|
||||
with self.assertRaises(PrestoSQLValidationError):
|
||||
self.validator.validate(sql, schema, self.database)
|
||||
|
||||
@patch("superset.sql_validators.presto_db.g")
|
||||
@patch("superset.utils.core.g")
|
||||
def test_validator_unexpected_error(self, flask_g):
|
||||
flask_g.user.username = "nobody"
|
||||
sql = "SELECT 1 FROM default.notarealtable"
|
||||
@@ -221,7 +221,7 @@ class TestPrestoValidator(SupersetTestCase):
|
||||
with self.assertRaises(Exception):
|
||||
self.validator.validate(sql, schema, self.database)
|
||||
|
||||
@patch("superset.sql_validators.presto_db.g")
|
||||
@patch("superset.utils.core.g")
|
||||
def test_validator_query_error(self, flask_g):
|
||||
flask_g.user.username = "nobody"
|
||||
sql = "SELECT 1 FROM default.notarealtable"
|
||||
|
||||
Reference in New Issue
Block a user