mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix(dev/ci): pre-commit fixes galore (#32352)
This commit is contained in:
@@ -226,7 +226,7 @@ def test_excel_reader_wrong_date():
|
||||
with pytest.raises(DatabaseUploadFailed) as ex:
|
||||
excel_reader.file_to_dataframe(create_excel_file(EXCEL_DATA))
|
||||
assert str(ex.value) == (
|
||||
"Parsing error: Missing column provided to 'parse_dates':" " 'xpto' (sheet: 0)"
|
||||
"Parsing error: Missing column provided to 'parse_dates': 'xpto' (sheet: 0)"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -187,13 +187,10 @@ def test_query_datasources_by_permissions_with_catalog_schema(
|
||||
["[my_db].[db1].[schema1]", "[my_other_db].[schema]"], # type: ignore
|
||||
)
|
||||
clause = db.session.query().filter_by().filter.mock_calls[0].args[0]
|
||||
assert (
|
||||
str(clause.compile(engine, compile_kwargs={"literal_binds": True}))
|
||||
== (
|
||||
"tables.perm IN ('[my_db].[table1](id:1)') OR "
|
||||
"tables.schema_perm IN ('[my_db].[db1].[schema1]', '[my_other_db].[schema]') OR " # noqa: E501
|
||||
"tables.catalog_perm IN ('[my_db].[db1]')"
|
||||
)
|
||||
assert str(clause.compile(engine, compile_kwargs={"literal_binds": True})) == (
|
||||
"tables.perm IN ('[my_db].[table1](id:1)') OR "
|
||||
"tables.schema_perm IN ('[my_db].[db1].[schema1]', '[my_other_db].[schema]') OR " # noqa: E501
|
||||
"tables.catalog_perm IN ('[my_db].[db1]')"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -64,8 +64,7 @@ def test_put_invalid_dataset(
|
||||
{
|
||||
"code": 1040,
|
||||
"message": (
|
||||
"Issue 1040 - The submitted payload "
|
||||
"failed validation."
|
||||
"Issue 1040 - The submitted payload failed validation."
|
||||
),
|
||||
}
|
||||
],
|
||||
|
||||
@@ -126,7 +126,7 @@ extra:
|
||||
warning_markdown: '*WARNING*'
|
||||
normalize_columns: false
|
||||
always_filter_main_dttm: false
|
||||
uuid: {payload['uuid']}
|
||||
uuid: {payload["uuid"]}
|
||||
metrics:
|
||||
- metric_name: cnt
|
||||
verbose_name: null
|
||||
|
||||
@@ -120,61 +120,58 @@ def test_validate_parameters_catalog(
|
||||
}
|
||||
errors = GSheetsEngineSpec.validate_parameters(properties) # ignore: type
|
||||
|
||||
assert (
|
||||
errors
|
||||
== [
|
||||
SupersetError(
|
||||
message=(
|
||||
"The URL could not be identified. Please check for typos "
|
||||
"and make sure that ‘Type of Google Sheets allowed’ "
|
||||
"selection matches the input."
|
||||
),
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"catalog": {
|
||||
"idx": 0,
|
||||
"url": True,
|
||||
},
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
|
||||
},
|
||||
],
|
||||
},
|
||||
assert errors == [
|
||||
SupersetError(
|
||||
message=(
|
||||
"The URL could not be identified. Please check for typos "
|
||||
"and make sure that ‘Type of Google Sheets allowed’ "
|
||||
"selection matches the input."
|
||||
),
|
||||
SupersetError(
|
||||
message=(
|
||||
"The URL could not be identified. Please check for typos "
|
||||
"and make sure that ‘Type of Google Sheets allowed’ "
|
||||
"selection matches the input."
|
||||
),
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"catalog": {
|
||||
"idx": 2,
|
||||
"url": True,
|
||||
},
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
|
||||
},
|
||||
],
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"catalog": {
|
||||
"idx": 0,
|
||||
"url": True,
|
||||
},
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
SupersetError(
|
||||
message=(
|
||||
"The URL could not be identified. Please check for typos "
|
||||
"and make sure that ‘Type of Google Sheets allowed’ "
|
||||
"selection matches the input."
|
||||
),
|
||||
]
|
||||
)
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"catalog": {
|
||||
"idx": 2,
|
||||
"url": True,
|
||||
},
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.", # noqa: E501
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.", # noqa: E501
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
create_engine.assert_called_with(
|
||||
"gsheets://",
|
||||
|
||||
@@ -420,31 +420,28 @@ Adaptive Server connection failed (mssqldb.cxiotftzsypc.us-west-2.rds.amazonaws.
|
||||
result = MssqlEngineSpec.extract_errors(
|
||||
Exception(msg), context={"username": "testuser", "database": "testdb"}
|
||||
)
|
||||
assert (
|
||||
result
|
||||
== [
|
||||
SupersetError(
|
||||
message='Either the username "testuser", password, or database name "testdb" is incorrect.', # noqa: E501
|
||||
error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR,
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "Microsoft SQL Server",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1014,
|
||||
"message": "Issue 1014 - Either the username or "
|
||||
"the password is wrong.",
|
||||
},
|
||||
{
|
||||
"code": 1015,
|
||||
"message": "Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist.",
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
)
|
||||
assert result == [
|
||||
SupersetError(
|
||||
message='Either the username "testuser", password, or database name "testdb" is incorrect.', # noqa: E501
|
||||
error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR,
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "Microsoft SQL Server",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1014,
|
||||
"message": "Issue 1014 - Either the username or "
|
||||
"the password is wrong.",
|
||||
},
|
||||
{
|
||||
"code": 1015,
|
||||
"message": "Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist.",
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -223,9 +223,9 @@ def test_connection_errors(msg: str, expected: SupersetError) -> None:
|
||||
assert result == [expected]
|
||||
|
||||
|
||||
def _generate_gis_type_sanitization_test_cases() -> (
|
||||
list[tuple[str, int, Any, dict[str, Any]]]
|
||||
):
|
||||
def _generate_gis_type_sanitization_test_cases() -> list[
|
||||
tuple[str, int, Any, dict[str, Any]]
|
||||
]:
|
||||
if not ocient_is_installed():
|
||||
return []
|
||||
|
||||
|
||||
@@ -116,8 +116,8 @@ names_df = DataFrame(
|
||||
categories_df = DataFrame(
|
||||
{
|
||||
"constant": ["dummy" for _ in range(0, 101)],
|
||||
"category": [f"cat{i%3}" for i in range(0, 101)],
|
||||
"dept": [f"dept{i%5}" for i in range(0, 101)],
|
||||
"category": [f"cat{i % 3}" for i in range(0, 101)],
|
||||
"dept": [f"dept{i % 5}" for i in range(0, 101)],
|
||||
"name": [f"person{i}" for i in range(0, 101)],
|
||||
"asc_idx": [i for i in range(0, 101)], # noqa: C416
|
||||
"desc_idx": [i for i in range(100, -1, -1)], # noqa: C416
|
||||
|
||||
Reference in New Issue
Block a user