chore: `s/MockFixture/MockerFixture/g` (#29160)
This commit is contained in:
parent
bfae2c8348
commit
8e15d4807f
|
|
@ -22,7 +22,7 @@ from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask.ctx import AppContext
|
from flask.ctx import AppContext
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy import inspect # noqa: F401
|
from sqlalchemy import inspect # noqa: F401
|
||||||
|
|
||||||
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||||
|
|
@ -90,7 +90,7 @@ SCHEMA_ACCESS_ROLE = "schema_access_role"
|
||||||
)
|
)
|
||||||
def test_get_user_id(
|
def test_get_user_id(
|
||||||
app_context: AppContext,
|
app_context: AppContext,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
username: Optional[str],
|
username: Optional[str],
|
||||||
user_id: Optional[int],
|
user_id: Optional[int],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -109,7 +109,7 @@ def test_get_user_id(
|
||||||
)
|
)
|
||||||
def test_get_username(
|
def test_get_username(
|
||||||
app_context: AppContext,
|
app_context: AppContext,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
username: Optional[str],
|
username: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
mock_g = mocker.patch("superset.utils.core.g", spec={})
|
mock_g = mocker.patch("superset.utils.core.g", spec={})
|
||||||
|
|
@ -121,7 +121,7 @@ def test_get_username(
|
||||||
@pytest.mark.parametrize("force", [False, True])
|
@pytest.mark.parametrize("force", [False, True])
|
||||||
def test_override_user(
|
def test_override_user(
|
||||||
app_context: AppContext,
|
app_context: AppContext,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
username: str,
|
username: str,
|
||||||
force: bool,
|
force: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from typing import Optional, Union
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pytest
|
import pytest
|
||||||
from flask.ctx import AppContext
|
from flask.ctx import AppContext
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.commands.report.exceptions import AlertQueryError
|
from superset.commands.report.exceptions import AlertQueryError
|
||||||
from superset.reports.models import ReportCreationMethod, ReportScheduleType
|
from superset.reports.models import ReportCreationMethod, ReportScheduleType
|
||||||
|
|
@ -61,7 +61,7 @@ def test_execute_query_as_report_executor(
|
||||||
creator_name: Optional[str],
|
creator_name: Optional[str],
|
||||||
config: list[ExecutorType],
|
config: list[ExecutorType],
|
||||||
expected_result: Union[tuple[ExecutorType, str], Exception],
|
expected_result: Union[tuple[ExecutorType, str], Exception],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: AppContext,
|
app_context: AppContext,
|
||||||
get_user,
|
get_user,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -99,7 +99,7 @@ def test_execute_query_as_report_executor(
|
||||||
|
|
||||||
|
|
||||||
def test_execute_query_succeeded_no_retry(
|
def test_execute_query_succeeded_no_retry(
|
||||||
mocker: MockFixture, app_context: None
|
mocker: MockerFixture, app_context: None
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.commands.report.alert import AlertCommand
|
from superset.commands.report.alert import AlertCommand
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ def test_execute_query_succeeded_no_retry(
|
||||||
|
|
||||||
|
|
||||||
def test_execute_query_succeeded_with_retries(
|
def test_execute_query_succeeded_with_retries(
|
||||||
mocker: MockFixture, app_context: None
|
mocker: MockerFixture, app_context: None
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.commands.report.alert import AlertCommand, AlertQueryError
|
from superset.commands.report.alert import AlertCommand, AlertQueryError
|
||||||
|
|
||||||
|
|
@ -147,7 +147,9 @@ def test_execute_query_succeeded_with_retries(
|
||||||
assert execute_query_mock.call_count == expected_max_retries
|
assert execute_query_mock.call_count == expected_max_retries
|
||||||
|
|
||||||
|
|
||||||
def test_execute_query_failed_no_retry(mocker: MockFixture, app_context: None) -> None:
|
def test_execute_query_failed_no_retry(
|
||||||
|
mocker: MockerFixture, app_context: None
|
||||||
|
) -> None:
|
||||||
from superset.commands.report.alert import AlertCommand, AlertQueryTimeout
|
from superset.commands.report.alert import AlertCommand, AlertQueryTimeout
|
||||||
|
|
||||||
execute_query_mock = mocker.patch(
|
execute_query_mock = mocker.patch(
|
||||||
|
|
@ -168,7 +170,7 @@ def test_execute_query_failed_no_retry(mocker: MockFixture, app_context: None) -
|
||||||
|
|
||||||
|
|
||||||
def test_execute_query_failed_max_retries(
|
def test_execute_query_failed_max_retries(
|
||||||
mocker: MockFixture, app_context: None
|
mocker: MockerFixture, app_context: None
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.commands.report.alert import AlertCommand, AlertQueryError
|
from superset.commands.report.alert import AlertCommand, AlertQueryError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import pytest
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from flask.ctx import AppContext
|
from flask.ctx import AppContext
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.sql import text
|
from sqlalchemy.sql import text
|
||||||
from sqlalchemy.sql.elements import TextClause
|
from sqlalchemy.sql.elements import TextClause
|
||||||
|
|
||||||
|
|
@ -856,7 +856,7 @@ def test_none_operand_in_filter(login_as_admin, physical_dataset):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__normalize_prequery_result_type(
|
def test__normalize_prequery_result_type(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
row: pd.Series,
|
row: pd.Series,
|
||||||
dimension: str,
|
dimension: str,
|
||||||
result: Any,
|
result: Any,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask.ctx import AppContext
|
from flask.ctx import AppContext
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
import superset.utils.database
|
import superset.utils.database
|
||||||
from superset.exceptions import SupersetTemplateException
|
from superset.exceptions import SupersetTemplateException
|
||||||
|
|
@ -109,7 +109,7 @@ def test_template_kwarg_nested_module(app_context: AppContext) -> None:
|
||||||
tp.process_template(template, foo={"bar": datetime})
|
tp.process_template(template, foo={"bar": datetime})
|
||||||
|
|
||||||
|
|
||||||
def test_template_hive(app_context: AppContext, mocker: MockFixture) -> None:
|
def test_template_hive(app_context: AppContext, mocker: MockerFixture) -> None:
|
||||||
lp_mock = mocker.patch(
|
lp_mock = mocker.patch(
|
||||||
"superset.jinja_context.HiveTemplateProcessor.latest_partition"
|
"superset.jinja_context.HiveTemplateProcessor.latest_partition"
|
||||||
)
|
)
|
||||||
|
|
@ -121,7 +121,7 @@ def test_template_hive(app_context: AppContext, mocker: MockFixture) -> None:
|
||||||
assert tp.process_template(template) == "the_latest"
|
assert tp.process_template(template) == "the_latest"
|
||||||
|
|
||||||
|
|
||||||
def test_template_spark(app_context: AppContext, mocker: MockFixture) -> None:
|
def test_template_spark(app_context: AppContext, mocker: MockerFixture) -> None:
|
||||||
lp_mock = mocker.patch(
|
lp_mock = mocker.patch(
|
||||||
"superset.jinja_context.SparkTemplateProcessor.latest_partition"
|
"superset.jinja_context.SparkTemplateProcessor.latest_partition"
|
||||||
)
|
)
|
||||||
|
|
@ -138,7 +138,7 @@ def test_template_spark(app_context: AppContext, mocker: MockFixture) -> None:
|
||||||
assert tp.process_template(template) == "the_latest"
|
assert tp.process_template(template) == "the_latest"
|
||||||
|
|
||||||
|
|
||||||
def test_template_trino(app_context: AppContext, mocker: MockFixture) -> None:
|
def test_template_trino(app_context: AppContext, mocker: MockerFixture) -> None:
|
||||||
lp_mock = mocker.patch(
|
lp_mock = mocker.patch(
|
||||||
"superset.jinja_context.TrinoTemplateProcessor.latest_partition"
|
"superset.jinja_context.TrinoTemplateProcessor.latest_partition"
|
||||||
)
|
)
|
||||||
|
|
@ -155,7 +155,9 @@ def test_template_trino(app_context: AppContext, mocker: MockFixture) -> None:
|
||||||
assert tp.process_template(template) == "the_latest"
|
assert tp.process_template(template) == "the_latest"
|
||||||
|
|
||||||
|
|
||||||
def test_template_context_addons(app_context: AppContext, mocker: MockFixture) -> None:
|
def test_template_context_addons(
|
||||||
|
app_context: AppContext, mocker: MockerFixture
|
||||||
|
) -> None:
|
||||||
addons_mock = mocker.patch("superset.jinja_context.context_addons")
|
addons_mock = mocker.patch("superset.jinja_context.context_addons")
|
||||||
addons_mock.return_value = {"datetime": datetime}
|
addons_mock.return_value = {"datetime": datetime}
|
||||||
maindb = superset.utils.database.get_example_database()
|
maindb = superset.utils.database.get_example_database()
|
||||||
|
|
@ -164,7 +166,9 @@ def test_template_context_addons(app_context: AppContext, mocker: MockFixture) -
|
||||||
assert tp.process_template(template) == "SELECT '2017-01-01T00:00:00'"
|
assert tp.process_template(template) == "SELECT '2017-01-01T00:00:00'"
|
||||||
|
|
||||||
|
|
||||||
def test_custom_process_template(app_context: AppContext, mocker: MockFixture) -> None:
|
def test_custom_process_template(
|
||||||
|
app_context: AppContext, mocker: MockerFixture
|
||||||
|
) -> None:
|
||||||
"""Test macro defined in custom template processor works."""
|
"""Test macro defined in custom template processor works."""
|
||||||
|
|
||||||
mock_dt = mocker.patch(
|
mock_dt = mocker.patch(
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from collections.abc import Generator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask_appbuilder.security.sqla.models import Role, User
|
from flask_appbuilder.security.sqla.models import Role, User
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import security_manager
|
from superset import security_manager
|
||||||
|
|
@ -71,7 +71,7 @@ def session_with_schema(session: Session) -> Generator[Session, None, None]:
|
||||||
yield session
|
yield session
|
||||||
|
|
||||||
|
|
||||||
def test_import_chart(mocker: MockFixture, session_with_schema: Session) -> None:
|
def test_import_chart(mocker: MockerFixture, session_with_schema: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a chart.
|
Test importing a chart.
|
||||||
"""
|
"""
|
||||||
|
|
@ -93,7 +93,7 @@ def test_import_chart(mocker: MockFixture, session_with_schema: Session) -> None
|
||||||
|
|
||||||
|
|
||||||
def test_import_chart_managed_externally(
|
def test_import_chart_managed_externally(
|
||||||
mocker: MockFixture, session_with_schema: Session
|
mocker: MockerFixture, session_with_schema: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a chart that is managed externally.
|
Test importing a chart that is managed externally.
|
||||||
|
|
@ -115,7 +115,7 @@ def test_import_chart_managed_externally(
|
||||||
|
|
||||||
|
|
||||||
def test_import_chart_without_permission(
|
def test_import_chart_without_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_schema: Session,
|
session_with_schema: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -156,7 +156,7 @@ def test_filter_chart_annotations(session: Session) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_import_existing_chart_without_permission(
|
def test_import_existing_chart_without_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_data: Session,
|
session_with_data: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -185,7 +185,7 @@ def test_import_existing_chart_without_permission(
|
||||||
|
|
||||||
|
|
||||||
def test_import_existing_chart_with_permission(
|
def test_import_existing_chart_with_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_data: Session,
|
session_with_data: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
from superset.commands.dataset.exceptions import DatasetInvalidError
|
from superset.commands.dataset.exceptions import DatasetInvalidError
|
||||||
|
|
@ -27,7 +27,7 @@ from superset.models.core import Database
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixture("session")
|
@pytest.mark.usefixture("session")
|
||||||
def test_update_uniqueness_error(mocker: MockFixture) -> None:
|
def test_update_uniqueness_error(mocker: MockerFixture) -> None:
|
||||||
SqlaTable.metadata.create_all(db.session.get_bind())
|
SqlaTable.metadata.create_all(db.session.get_bind())
|
||||||
database = Database(database_name="my_db", sqlalchemy_uri="sqlite://")
|
database = Database(database_name="my_db", sqlalchemy_uri="sqlite://")
|
||||||
bar = SqlaTable(table_name="bar", schema="foo", database=database)
|
bar = SqlaTable(table_name="bar", schema="foo", database=database)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
# pylint: disable=invalid-name, unused-argument, import-outside-toplevel
|
# pylint: disable=invalid-name, unused-argument, import-outside-toplevel
|
||||||
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
|
|
||||||
def test_export_assets_command(mocker: MockFixture) -> None:
|
def test_export_assets_command(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test that all assets are exported correctly.
|
Test that all assets are exported correctly.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
from sqlalchemy.sql import select
|
from sqlalchemy.sql import select
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ from tests.unit_tests.fixtures.assets_configs import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_import_new_assets(mocker: MockFixture, session: Session) -> None:
|
def test_import_new_assets(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test that all new assets are imported correctly.
|
Test that all new assets are imported correctly.
|
||||||
"""
|
"""
|
||||||
|
|
@ -63,7 +63,7 @@ def test_import_new_assets(mocker: MockFixture, session: Session) -> None:
|
||||||
assert len(dashboard_ids) == expected_number_of_dashboards
|
assert len(dashboard_ids) == expected_number_of_dashboards
|
||||||
|
|
||||||
|
|
||||||
def test_import_adds_dashboard_charts(mocker: MockFixture, session: Session) -> None:
|
def test_import_adds_dashboard_charts(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test that existing dashboards are updated with new charts.
|
Test that existing dashboards are updated with new charts.
|
||||||
"""
|
"""
|
||||||
|
|
@ -102,7 +102,9 @@ def test_import_adds_dashboard_charts(mocker: MockFixture, session: Session) ->
|
||||||
assert len(dashboard_ids) == expected_number_of_dashboards
|
assert len(dashboard_ids) == expected_number_of_dashboards
|
||||||
|
|
||||||
|
|
||||||
def test_import_removes_dashboard_charts(mocker: MockFixture, session: Session) -> None:
|
def test_import_removes_dashboard_charts(
|
||||||
|
mocker: MockerFixture, session: Session
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test that existing dashboards are updated without old charts.
|
Test that existing dashboards are updated without old charts.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.fixtures import SubRequest
|
from _pytest.fixtures import SubRequest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
@ -39,7 +39,7 @@ from superset.initialization import SupersetAppInitializer
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def get_session(mocker: MockFixture) -> Callable[[], Session]:
|
def get_session(mocker: MockerFixture) -> Callable[[], Session]:
|
||||||
"""
|
"""
|
||||||
Create an in-memory SQLite db.session.to test models.
|
Create an in-memory SQLite db.session.to test models.
|
||||||
"""
|
"""
|
||||||
|
|
@ -141,7 +141,7 @@ def app_context(app: SupersetApp) -> Iterator[None]:
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def full_api_access(mocker: MockFixture) -> Iterator[None]:
|
def full_api_access(mocker: MockerFixture) -> Iterator[None]:
|
||||||
"""
|
"""
|
||||||
Allow full access to the API.
|
Allow full access to the API.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ from datetime import datetime, timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset.exceptions import QueryNotFoundException, SupersetCancelQueryException
|
from superset.exceptions import QueryNotFoundException, SupersetCancelQueryException
|
||||||
|
|
@ -116,7 +116,7 @@ def test_query_dao_get_queries_changed_after(session: Session) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_query_dao_stop_query_not_found(
|
def test_query_dao_stop_query_not_found(
|
||||||
mocker: MockFixture, app: Any, session: Session
|
mocker: MockerFixture, app: Any, session: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset import db
|
from superset import db
|
||||||
from superset.common.db_query_status import QueryStatus
|
from superset.common.db_query_status import QueryStatus
|
||||||
|
|
@ -159,7 +159,7 @@ def test_query_dao_stop_query_not_found(
|
||||||
|
|
||||||
|
|
||||||
def test_query_dao_stop_query_not_running(
|
def test_query_dao_stop_query_not_running(
|
||||||
mocker: MockFixture, app: Any, session: Session
|
mocker: MockerFixture, app: Any, session: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset import db
|
from superset import db
|
||||||
from superset.common.db_query_status import QueryStatus
|
from superset.common.db_query_status import QueryStatus
|
||||||
|
|
@ -198,7 +198,7 @@ def test_query_dao_stop_query_not_running(
|
||||||
|
|
||||||
|
|
||||||
def test_query_dao_stop_query_failed(
|
def test_query_dao_stop_query_failed(
|
||||||
mocker: MockFixture, app: Any, session: Session
|
mocker: MockerFixture, app: Any, session: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset import db
|
from superset import db
|
||||||
from superset.common.db_query_status import QueryStatus
|
from superset.common.db_query_status import QueryStatus
|
||||||
|
|
@ -240,7 +240,9 @@ def test_query_dao_stop_query_failed(
|
||||||
assert query.status == QueryStatus.RUNNING
|
assert query.status == QueryStatus.RUNNING
|
||||||
|
|
||||||
|
|
||||||
def test_query_dao_stop_query(mocker: MockFixture, app: Any, session: Session) -> None:
|
def test_query_dao_stop_query(
|
||||||
|
mocker: MockerFixture, app: Any, session: Session
|
||||||
|
) -> None:
|
||||||
from superset import db
|
from superset import db
|
||||||
from superset.common.db_query_status import QueryStatus
|
from superset.common.db_query_status import QueryStatus
|
||||||
from superset.models.core import Database
|
from superset.models.core import Database
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from collections.abc import Generator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask_appbuilder.security.sqla.models import Role, User
|
from flask_appbuilder.security.sqla.models import Role, User
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import security_manager
|
from superset import security_manager
|
||||||
|
|
@ -61,7 +61,7 @@ def session_with_schema(session: Session) -> Generator[Session, None, None]:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
|
||||||
|
|
||||||
def test_import_dashboard(mocker: MockFixture, session_with_schema: Session) -> None:
|
def test_import_dashboard(mocker: MockerFixture, session_with_schema: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a dashboard.
|
Test importing a dashboard.
|
||||||
"""
|
"""
|
||||||
|
|
@ -77,7 +77,7 @@ def test_import_dashboard(mocker: MockFixture, session_with_schema: Session) ->
|
||||||
|
|
||||||
|
|
||||||
def test_import_dashboard_managed_externally(
|
def test_import_dashboard_managed_externally(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_schema: Session,
|
session_with_schema: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -97,7 +97,7 @@ def test_import_dashboard_managed_externally(
|
||||||
|
|
||||||
|
|
||||||
def test_import_dashboard_without_permission(
|
def test_import_dashboard_without_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_schema: Session,
|
session_with_schema: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -117,7 +117,7 @@ def test_import_dashboard_without_permission(
|
||||||
|
|
||||||
|
|
||||||
def test_import_existing_dashboard_without_permission(
|
def test_import_existing_dashboard_without_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_data: Session,
|
session_with_data: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -146,7 +146,7 @@ def test_import_existing_dashboard_without_permission(
|
||||||
|
|
||||||
|
|
||||||
def test_import_existing_dashboard_with_permission(
|
def test_import_existing_dashboard_with_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session_with_data: Session,
|
session_with_data: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from uuid import UUID
|
||||||
import pytest
|
import pytest
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
|
|
@ -120,7 +120,7 @@ def test_post_with_uuid(
|
||||||
|
|
||||||
|
|
||||||
def test_password_mask(
|
def test_password_mask(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app: Any,
|
app: Any,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
|
|
@ -176,7 +176,7 @@ def test_password_mask(
|
||||||
|
|
||||||
|
|
||||||
def test_database_connection(
|
def test_database_connection(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app: Any,
|
app: Any,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
|
|
@ -409,7 +409,7 @@ def test_non_zip_import(client: Any, full_api_access: None) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_delete_ssh_tunnel(
|
def test_delete_ssh_tunnel(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app: Any,
|
app: Any,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
|
|
@ -487,7 +487,7 @@ def test_delete_ssh_tunnel(
|
||||||
|
|
||||||
|
|
||||||
def test_delete_ssh_tunnel_not_found(
|
def test_delete_ssh_tunnel_not_found(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app: Any,
|
app: Any,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
|
|
@ -563,7 +563,7 @@ def test_delete_ssh_tunnel_not_found(
|
||||||
|
|
||||||
|
|
||||||
def test_apply_dynamic_database_filter(
|
def test_apply_dynamic_database_filter(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app: Any,
|
app: Any,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
|
|
@ -659,7 +659,7 @@ def test_apply_dynamic_database_filter(
|
||||||
|
|
||||||
|
|
||||||
def test_oauth2_happy_path(
|
def test_oauth2_happy_path(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
|
|
@ -727,7 +727,7 @@ def test_oauth2_happy_path(
|
||||||
|
|
||||||
|
|
||||||
def test_oauth2_multiple_tokens(
|
def test_oauth2_multiple_tokens(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
|
|
@ -807,7 +807,7 @@ def test_oauth2_multiple_tokens(
|
||||||
|
|
||||||
|
|
||||||
def test_oauth2_error(
|
def test_oauth2_error(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
|
|
@ -930,7 +930,7 @@ def test_csv_upload(
|
||||||
payload: dict[str, Any],
|
payload: dict[str, Any],
|
||||||
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
||||||
reader_called_with: dict[str, Any],
|
reader_called_with: dict[str, Any],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1070,7 +1070,7 @@ def test_csv_upload(
|
||||||
def test_csv_upload_validation(
|
def test_csv_upload_validation(
|
||||||
payload: Any,
|
payload: Any,
|
||||||
expected_response: dict[str, str],
|
expected_response: dict[str, str],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1089,7 +1089,7 @@ def test_csv_upload_validation(
|
||||||
|
|
||||||
|
|
||||||
def test_csv_upload_file_size_validation(
|
def test_csv_upload_file_size_validation(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1131,7 +1131,7 @@ def test_csv_upload_file_size_validation(
|
||||||
)
|
)
|
||||||
def test_csv_upload_file_extension_invalid(
|
def test_csv_upload_file_extension_invalid(
|
||||||
filename: str,
|
filename: str,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1167,7 +1167,7 @@ def test_csv_upload_file_extension_invalid(
|
||||||
)
|
)
|
||||||
def test_csv_upload_file_extension_valid(
|
def test_csv_upload_file_extension_valid(
|
||||||
filename: str,
|
filename: str,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1272,7 +1272,7 @@ def test_excel_upload(
|
||||||
payload: dict[str, Any],
|
payload: dict[str, Any],
|
||||||
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
||||||
reader_called_with: dict[str, Any],
|
reader_called_with: dict[str, Any],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1367,7 +1367,7 @@ def test_excel_upload(
|
||||||
def test_excel_upload_validation(
|
def test_excel_upload_validation(
|
||||||
payload: Any,
|
payload: Any,
|
||||||
expected_response: dict[str, str],
|
expected_response: dict[str, str],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1402,7 +1402,7 @@ def test_excel_upload_validation(
|
||||||
)
|
)
|
||||||
def test_excel_upload_file_extension_invalid(
|
def test_excel_upload_file_extension_invalid(
|
||||||
filename: str,
|
filename: str,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1478,7 +1478,7 @@ def test_columnar_upload(
|
||||||
payload: dict[str, Any],
|
payload: dict[str, Any],
|
||||||
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
upload_called_with: tuple[int, str, Any, dict[str, Any]],
|
||||||
reader_called_with: dict[str, Any],
|
reader_called_with: dict[str, Any],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1544,7 +1544,7 @@ def test_columnar_upload(
|
||||||
def test_columnar_upload_validation(
|
def test_columnar_upload_validation(
|
||||||
payload: Any,
|
payload: Any,
|
||||||
expected_response: dict[str, str],
|
expected_response: dict[str, str],
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1574,7 +1574,7 @@ def test_columnar_upload_validation(
|
||||||
)
|
)
|
||||||
def test_columnar_upload_file_extension_valid(
|
def test_columnar_upload_file_extension_valid(
|
||||||
filename: str,
|
filename: str,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1610,7 +1610,7 @@ def test_columnar_upload_file_extension_valid(
|
||||||
)
|
)
|
||||||
def test_columnar_upload_file_extension_invalid(
|
def test_columnar_upload_file_extension_invalid(
|
||||||
filename: str,
|
filename: str,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1630,7 +1630,9 @@ def test_columnar_upload_file_extension_invalid(
|
||||||
assert response.json == {"message": {"file": ["File extension is not allowed."]}}
|
assert response.json == {"message": {"file": ["File extension is not allowed."]}}
|
||||||
|
|
||||||
|
|
||||||
def test_csv_metadata(mocker: MockFixture, client: Any, full_api_access: None) -> None:
|
def test_csv_metadata(
|
||||||
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
|
) -> None:
|
||||||
_ = mocker.patch.object(CSVReader, "file_metadata")
|
_ = mocker.patch.object(CSVReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/api/v1/database/csv_metadata/",
|
"/api/v1/database/csv_metadata/",
|
||||||
|
|
@ -1641,7 +1643,7 @@ def test_csv_metadata(mocker: MockFixture, client: Any, full_api_access: None) -
|
||||||
|
|
||||||
|
|
||||||
def test_csv_metadata_bad_extension(
|
def test_csv_metadata_bad_extension(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(CSVReader, "file_metadata")
|
_ = mocker.patch.object(CSVReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1654,7 +1656,7 @@ def test_csv_metadata_bad_extension(
|
||||||
|
|
||||||
|
|
||||||
def test_csv_metadata_validation(
|
def test_csv_metadata_validation(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(CSVReader, "file_metadata")
|
_ = mocker.patch.object(CSVReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1667,7 +1669,7 @@ def test_csv_metadata_validation(
|
||||||
|
|
||||||
|
|
||||||
def test_excel_metadata(
|
def test_excel_metadata(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1679,7 +1681,7 @@ def test_excel_metadata(
|
||||||
|
|
||||||
|
|
||||||
def test_excel_metadata_bad_extension(
|
def test_excel_metadata_bad_extension(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1692,7 +1694,7 @@ def test_excel_metadata_bad_extension(
|
||||||
|
|
||||||
|
|
||||||
def test_excel_metadata_validation(
|
def test_excel_metadata_validation(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
_ = mocker.patch.object(ExcelReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1705,7 +1707,7 @@ def test_excel_metadata_validation(
|
||||||
|
|
||||||
|
|
||||||
def test_columnar_metadata(
|
def test_columnar_metadata(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1717,7 +1719,7 @@ def test_columnar_metadata(
|
||||||
|
|
||||||
|
|
||||||
def test_columnar_metadata_bad_extension(
|
def test_columnar_metadata_bad_extension(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1730,7 +1732,7 @@ def test_columnar_metadata_bad_extension(
|
||||||
|
|
||||||
|
|
||||||
def test_columnar_metadata_validation(
|
def test_columnar_metadata_validation(
|
||||||
mocker: MockFixture, client: Any, full_api_access: None
|
mocker: MockerFixture, client: Any, full_api_access: None
|
||||||
) -> None:
|
) -> None:
|
||||||
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
_ = mocker.patch.object(ColumnarReader, "file_metadata")
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
|
@ -1743,7 +1745,7 @@ def test_columnar_metadata_validation(
|
||||||
|
|
||||||
|
|
||||||
def test_table_metadata_happy_path(
|
def test_table_metadata_happy_path(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1784,7 +1786,7 @@ def test_table_metadata_happy_path(
|
||||||
|
|
||||||
|
|
||||||
def test_table_metadata_no_table(
|
def test_table_metadata_no_table(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1817,7 +1819,7 @@ def test_table_metadata_no_table(
|
||||||
|
|
||||||
|
|
||||||
def test_table_metadata_slashes(
|
def test_table_metadata_slashes(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1837,7 +1839,7 @@ def test_table_metadata_slashes(
|
||||||
|
|
||||||
|
|
||||||
def test_table_metadata_invalid_database(
|
def test_table_metadata_invalid_database(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1872,7 +1874,7 @@ def test_table_metadata_invalid_database(
|
||||||
|
|
||||||
|
|
||||||
def test_table_metadata_unauthorized(
|
def test_table_metadata_unauthorized(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1907,7 +1909,7 @@ def test_table_metadata_unauthorized(
|
||||||
|
|
||||||
|
|
||||||
def test_table_extra_metadata_happy_path(
|
def test_table_extra_metadata_happy_path(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1948,7 +1950,7 @@ def test_table_extra_metadata_happy_path(
|
||||||
|
|
||||||
|
|
||||||
def test_table_extra_metadata_no_table(
|
def test_table_extra_metadata_no_table(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -1981,7 +1983,7 @@ def test_table_extra_metadata_no_table(
|
||||||
|
|
||||||
|
|
||||||
def test_table_extra_metadata_slashes(
|
def test_table_extra_metadata_slashes(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -2001,7 +2003,7 @@ def test_table_extra_metadata_slashes(
|
||||||
|
|
||||||
|
|
||||||
def test_table_extra_metadata_invalid_database(
|
def test_table_extra_metadata_invalid_database(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -2036,7 +2038,7 @@ def test_table_extra_metadata_invalid_database(
|
||||||
|
|
||||||
|
|
||||||
def test_table_extra_metadata_unauthorized(
|
def test_table_extra_metadata_unauthorized(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -2071,7 +2073,7 @@ def test_table_extra_metadata_unauthorized(
|
||||||
|
|
||||||
|
|
||||||
def test_catalogs(
|
def test_catalogs(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -2111,7 +2113,7 @@ def test_catalogs(
|
||||||
|
|
||||||
|
|
||||||
def test_schemas(
|
def test_schemas(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
|
|
@ -27,7 +27,7 @@ from superset.commands.exceptions import ImportFailedError
|
||||||
from superset.utils import json
|
from superset.utils import json
|
||||||
|
|
||||||
|
|
||||||
def test_import_database(mocker: MockFixture, session: Session) -> None:
|
def test_import_database(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a database.
|
Test importing a database.
|
||||||
"""
|
"""
|
||||||
|
|
@ -67,7 +67,9 @@ def test_import_database(mocker: MockFixture, session: Session) -> None:
|
||||||
assert database.allow_dml is False
|
assert database.allow_dml is False
|
||||||
|
|
||||||
|
|
||||||
def test_import_database_sqlite_invalid(mocker: MockFixture, session: Session) -> None:
|
def test_import_database_sqlite_invalid(
|
||||||
|
mocker: MockerFixture, session: Session
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a database.
|
Test importing a database.
|
||||||
"""
|
"""
|
||||||
|
|
@ -94,7 +96,7 @@ def test_import_database_sqlite_invalid(mocker: MockFixture, session: Session) -
|
||||||
|
|
||||||
|
|
||||||
def test_import_database_managed_externally(
|
def test_import_database_managed_externally(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -120,7 +122,7 @@ def test_import_database_managed_externally(
|
||||||
|
|
||||||
|
|
||||||
def test_import_database_without_permission(
|
def test_import_database_without_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -146,7 +148,7 @@ def test_import_database_without_permission(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_import_database_with_version(mocker: MockFixture, session: Session) -> None:
|
def test_import_database_with_version(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a database with a version set.
|
Test importing a database with a version set.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from marshmallow import fields, Schema, ValidationError
|
from marshmallow import fields, Schema, ValidationError
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from superset.databases.schemas import DatabaseParametersSchemaMixin
|
from superset.databases.schemas import DatabaseParametersSchemaMixin
|
||||||
|
|
@ -48,7 +48,7 @@ def dummy_schema() -> "DatabaseParametersSchemaMixin":
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def dummy_engine(mocker: MockFixture) -> None:
|
def dummy_engine(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Fixture proving a dummy DB engine spec.
|
Fixture proving a dummy DB engine spec.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ def session_with_data(session: Session) -> Iterator[Session]:
|
||||||
|
|
||||||
|
|
||||||
def test_delete_ssh_tunnel_command(
|
def test_delete_ssh_tunnel_command(
|
||||||
mocker: MockFixture, session_with_data: Session
|
mocker: MockerFixture, session_with_data: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.commands.database.ssh_tunnel.delete import DeleteSSHTunnelCommand
|
from superset.commands.database.ssh_tunnel.delete import DeleteSSHTunnelCommand
|
||||||
from superset.daos.database import DatabaseDAO
|
from superset.daos.database import DatabaseDAO
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from unittest.mock import Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
|
|
@ -35,7 +35,7 @@ from superset.commands.dataset.importers.v1.utils import validate_data_uri
|
||||||
from superset.utils import json
|
from superset.utils import json
|
||||||
|
|
||||||
|
|
||||||
def test_import_dataset(mocker: MockFixture, session: Session) -> None:
|
def test_import_dataset(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a dataset.
|
Test importing a dataset.
|
||||||
"""
|
"""
|
||||||
|
|
@ -152,7 +152,9 @@ def test_import_dataset(mocker: MockFixture, session: Session) -> None:
|
||||||
assert sqla_table.database.id == database.id
|
assert sqla_table.database.id == database.id
|
||||||
|
|
||||||
|
|
||||||
def test_import_dataset_duplicate_column(mocker: MockFixture, session: Session) -> None:
|
def test_import_dataset_duplicate_column(
|
||||||
|
mocker: MockerFixture, session: Session
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a dataset with a column that already exists.
|
Test importing a dataset with a column that already exists.
|
||||||
"""
|
"""
|
||||||
|
|
@ -277,7 +279,7 @@ def test_import_dataset_duplicate_column(mocker: MockFixture, session: Session)
|
||||||
assert sqla_table.database.id == database.id
|
assert sqla_table.database.id == database.id
|
||||||
|
|
||||||
|
|
||||||
def test_import_column_extra_is_string(mocker: MockFixture, session: Session) -> None:
|
def test_import_column_extra_is_string(mocker: MockerFixture, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a dataset when the column extra is a string.
|
Test importing a dataset when the column extra is a string.
|
||||||
"""
|
"""
|
||||||
|
|
@ -361,7 +363,7 @@ def test_import_column_extra_is_string(mocker: MockFixture, session: Session) ->
|
||||||
|
|
||||||
|
|
||||||
def test_import_dataset_extra_empty_string(
|
def test_import_dataset_extra_empty_string(
|
||||||
mocker: MockFixture, session: Session
|
mocker: MockerFixture, session: Session
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test importing a dataset when the extra field is an empty string.
|
Test importing a dataset when the extra field is an empty string.
|
||||||
|
|
@ -426,7 +428,7 @@ def test_import_dataset_extra_empty_string(
|
||||||
@patch("superset.commands.dataset.importers.v1.utils.request")
|
@patch("superset.commands.dataset.importers.v1.utils.request")
|
||||||
def test_import_column_allowed_data_url(
|
def test_import_column_allowed_data_url(
|
||||||
request: Mock,
|
request: Mock,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -503,7 +505,7 @@ def test_import_column_allowed_data_url(
|
||||||
|
|
||||||
|
|
||||||
def test_import_dataset_managed_externally(
|
def test_import_dataset_managed_externally(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
session: Session,
|
session: Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from textwrap import dedent
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy import types
|
from sqlalchemy import types
|
||||||
from sqlalchemy.dialects import sqlite
|
from sqlalchemy.dialects import sqlite
|
||||||
from sqlalchemy.engine.url import URL
|
from sqlalchemy.engine.url import URL
|
||||||
|
|
@ -74,7 +74,7 @@ def test_parse_sql_multi_statement() -> None:
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_validate_db_uri(mocker: MockFixture) -> None:
|
def test_validate_db_uri(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Ensures that the `validate_database_uri` method invokes the validator correctly
|
Ensures that the `validate_database_uri` method invokes the validator correctly
|
||||||
"""
|
"""
|
||||||
|
|
@ -197,7 +197,7 @@ def test_convert_inspector_columns(
|
||||||
assert convert_inspector_columns(cols) == expected_result
|
assert convert_inspector_columns(cols) == expected_result
|
||||||
|
|
||||||
|
|
||||||
def test_select_star(mocker: MockFixture) -> None:
|
def test_select_star(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``select_star`` method.
|
Test the ``select_star`` method.
|
||||||
"""
|
"""
|
||||||
|
|
@ -267,7 +267,7 @@ FROM my_table"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_extra_table_metadata(mocker: MockFixture) -> None:
|
def test_extra_table_metadata(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the deprecated `extra_table_metadata` method.
|
Test the deprecated `extra_table_metadata` method.
|
||||||
"""
|
"""
|
||||||
|
|
@ -303,7 +303,7 @@ def test_extra_table_metadata(mocker: MockFixture) -> None:
|
||||||
warnings.warn.assert_called()
|
warnings.warn.assert_called()
|
||||||
|
|
||||||
|
|
||||||
def test_get_default_catalog(mocker: MockFixture) -> None:
|
def test_get_default_catalog(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the `get_default_catalog` method.
|
Test the `get_default_catalog` method.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.engine.url import make_url
|
from sqlalchemy.engine.url import make_url
|
||||||
from sqlalchemy.sql import sqltypes
|
from sqlalchemy.sql import sqltypes
|
||||||
|
|
@ -86,7 +86,7 @@ def test_get_fields() -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_select_star(mocker: MockFixture) -> None:
|
def test_select_star(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``select_star`` method.
|
Test the ``select_star`` method.
|
||||||
|
|
||||||
|
|
@ -336,7 +336,7 @@ def test_convert_dttm(
|
||||||
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
||||||
|
|
||||||
|
|
||||||
def test_get_default_catalog(mocker: MockFixture) -> None:
|
def test_get_default_catalog(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test that we get the default catalog from the connection URI.
|
Test that we get the default catalog from the connection URI.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from urllib.parse import parse_qs, urlparse
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.engine.url import make_url
|
from sqlalchemy.engine.url import make_url
|
||||||
|
|
||||||
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
||||||
|
|
@ -91,7 +91,7 @@ def test_validate_parameters_simple_with_in_root_catalog() -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_validate_parameters_catalog(
|
def test_validate_parameters_catalog(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.db_engine_specs.gsheets import (
|
from superset.db_engine_specs.gsheets import (
|
||||||
GSheetsEngineSpec,
|
GSheetsEngineSpec,
|
||||||
|
|
@ -181,7 +181,7 @@ def test_validate_parameters_catalog(
|
||||||
|
|
||||||
|
|
||||||
def test_validate_parameters_catalog_and_credentials(
|
def test_validate_parameters_catalog_and_credentials(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
from superset.db_engine_specs.gsheets import (
|
from superset.db_engine_specs.gsheets import (
|
||||||
GSheetsEngineSpec,
|
GSheetsEngineSpec,
|
||||||
|
|
@ -321,7 +321,7 @@ def test_unmask_encrypted_extra_when_new_is_none() -> None:
|
||||||
assert GSheetsEngineSpec.unmask_encrypted_extra(old, new) is None
|
assert GSheetsEngineSpec.unmask_encrypted_extra(old, new) is None
|
||||||
|
|
||||||
|
|
||||||
def test_upload_new(mocker: MockFixture) -> None:
|
def test_upload_new(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test file upload when the table does not exist.
|
Test file upload when the table does not exist.
|
||||||
"""
|
"""
|
||||||
|
|
@ -350,7 +350,7 @@ def test_upload_new(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_upload_existing(mocker: MockFixture) -> None:
|
def test_upload_existing(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test file upload when the table does exist.
|
Test file upload when the table does exist.
|
||||||
"""
|
"""
|
||||||
|
|
@ -409,7 +409,7 @@ def test_upload_existing(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_url_for_impersonation_username(mocker: MockFixture) -> None:
|
def test_get_url_for_impersonation_username(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test passing a username to `get_url_for_impersonation`.
|
Test passing a username to `get_url_for_impersonation`.
|
||||||
"""
|
"""
|
||||||
|
|
@ -444,7 +444,7 @@ def test_get_url_for_impersonation_access_token() -> None:
|
||||||
) == make_url("gsheets://?access_token=access-token")
|
) == make_url("gsheets://?access_token=access-token")
|
||||||
|
|
||||||
|
|
||||||
def test_is_oauth2_enabled_no_config(mocker: MockFixture) -> None:
|
def test_is_oauth2_enabled_no_config(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test `is_oauth2_enabled` when OAuth2 is not configured.
|
Test `is_oauth2_enabled` when OAuth2 is not configured.
|
||||||
"""
|
"""
|
||||||
|
|
@ -458,7 +458,7 @@ def test_is_oauth2_enabled_no_config(mocker: MockFixture) -> None:
|
||||||
assert GSheetsEngineSpec.is_oauth2_enabled() is False
|
assert GSheetsEngineSpec.is_oauth2_enabled() is False
|
||||||
|
|
||||||
|
|
||||||
def test_is_oauth2_enabled_config(mocker: MockFixture) -> None:
|
def test_is_oauth2_enabled_config(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test `is_oauth2_enabled` when OAuth2 is configured.
|
Test `is_oauth2_enabled` when OAuth2 is configured.
|
||||||
"""
|
"""
|
||||||
|
|
@ -501,7 +501,7 @@ def oauth2_config() -> OAuth2ClientConfig:
|
||||||
|
|
||||||
|
|
||||||
def test_get_oauth2_authorization_uri(
|
def test_get_oauth2_authorization_uri(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
oauth2_config: OAuth2ClientConfig,
|
oauth2_config: OAuth2ClientConfig,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -532,7 +532,7 @@ def test_get_oauth2_authorization_uri(
|
||||||
|
|
||||||
|
|
||||||
def test_get_oauth2_token(
|
def test_get_oauth2_token(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
oauth2_config: OAuth2ClientConfig,
|
oauth2_config: OAuth2ClientConfig,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -570,7 +570,7 @@ def test_get_oauth2_token(
|
||||||
|
|
||||||
|
|
||||||
def test_get_oauth2_fresh_token(
|
def test_get_oauth2_fresh_token(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
oauth2_config: OAuth2ClientConfig,
|
oauth2_config: OAuth2ClientConfig,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.db_engine_specs import get_available_engine_specs
|
from superset.db_engine_specs import get_available_engine_specs
|
||||||
|
|
||||||
|
|
||||||
def test_get_available_engine_specs(mocker: MockFixture) -> None:
|
def test_get_available_engine_specs(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
get_available_engine_specs should return all engine specs
|
get_available_engine_specs should return all engine specs
|
||||||
"""
|
"""
|
||||||
|
|
@ -55,7 +55,7 @@ def test_get_available_engine_specs(mocker: MockFixture) -> None:
|
||||||
[{"DBS_AVAILABLE_DENYLIST": {"databricks": {"pyhive", "pyodbc"}}}],
|
[{"DBS_AVAILABLE_DENYLIST": {"databricks": {"pyhive", "pyodbc"}}}],
|
||||||
indirect=True,
|
indirect=True,
|
||||||
)
|
)
|
||||||
def test_get_available_engine_specs_with_denylist(mocker: MockFixture) -> None:
|
def test_get_available_engine_specs_with_denylist(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
The denylist removes items from the db engine spec list
|
The denylist removes items from the db engine spec list
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from datetime import datetime
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy import types
|
from sqlalchemy import types
|
||||||
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, ENUM, JSON
|
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, ENUM, JSON
|
||||||
from sqlalchemy.engine.url import make_url
|
from sqlalchemy.engine.url import make_url
|
||||||
|
|
@ -149,7 +149,7 @@ def test_get_prequeries() -> None:
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_get_default_schema_for_query(mocker: MockFixture) -> None:
|
def test_get_default_schema_for_query(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``get_default_schema_for_query`` method.
|
Test the ``get_default_schema_for_query`` method.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
from flask_appbuilder.security.sqla.models import User
|
from flask_appbuilder.security.sqla.models import User
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.commands.chart.exceptions import (
|
from superset.commands.chart.exceptions import (
|
||||||
ChartAccessDeniedError,
|
ChartAccessDeniedError,
|
||||||
|
|
@ -60,7 +60,7 @@ def test_unsaved_chart_no_dataset_id() -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unsaved_chart_unknown_dataset_id(mocker: MockFixture) -> None:
|
def test_unsaved_chart_unknown_dataset_id(mocker: MockerFixture) -> None:
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
with raises(DatasetNotFoundError):
|
with raises(DatasetNotFoundError):
|
||||||
|
|
@ -74,7 +74,7 @@ def test_unsaved_chart_unknown_dataset_id(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unsaved_chart_unknown_query_id(mocker: MockFixture) -> None:
|
def test_unsaved_chart_unknown_query_id(mocker: MockerFixture) -> None:
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
with raises(QueryNotFoundValidationError):
|
with raises(QueryNotFoundValidationError):
|
||||||
|
|
@ -88,7 +88,7 @@ def test_unsaved_chart_unknown_query_id(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unsaved_chart_unauthorized_dataset(mocker: MockFixture) -> None:
|
def test_unsaved_chart_unauthorized_dataset(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ def test_unsaved_chart_unauthorized_dataset(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unsaved_chart_authorized_dataset(mocker: MockFixture) -> None:
|
def test_unsaved_chart_authorized_dataset(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ def test_unsaved_chart_authorized_dataset(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_unknown_chart_id(mocker: MockFixture) -> None:
|
def test_saved_chart_unknown_chart_id(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ def test_saved_chart_unknown_chart_id(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_unauthorized_dataset(mocker: MockFixture) -> None:
|
def test_saved_chart_unauthorized_dataset(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ def test_saved_chart_unauthorized_dataset(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_is_admin(mocker: MockFixture) -> None:
|
def test_saved_chart_is_admin(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
@ -170,7 +170,7 @@ def test_saved_chart_is_admin(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_is_owner(mocker: MockFixture) -> None:
|
def test_saved_chart_is_owner(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
@ -189,7 +189,7 @@ def test_saved_chart_is_owner(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_has_access(mocker: MockFixture) -> None:
|
def test_saved_chart_has_access(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
@ -209,7 +209,7 @@ def test_saved_chart_has_access(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_saved_chart_no_access(mocker: MockFixture) -> None:
|
def test_saved_chart_no_access(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_access as check_chart_access
|
from superset.explore.utils import check_access as check_chart_access
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
@ -230,7 +230,7 @@ def test_saved_chart_no_access(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_dataset_has_access(mocker: MockFixture) -> None:
|
def test_dataset_has_access(mocker: MockerFixture) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_datasource_access
|
from superset.explore.utils import check_datasource_access
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ def test_dataset_has_access(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_query_has_access(mocker: MockFixture) -> None:
|
def test_query_has_access(mocker: MockerFixture) -> None:
|
||||||
from superset.explore.utils import check_datasource_access
|
from superset.explore.utils import check_datasource_access
|
||||||
from superset.models.sql_lab import Query
|
from superset.models.sql_lab import Query
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ def test_query_has_access(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_query_no_access(mocker: MockFixture, client) -> None:
|
def test_query_no_access(mocker: MockerFixture, client) -> None:
|
||||||
from superset.connectors.sqla.models import SqlaTable
|
from superset.connectors.sqla.models import SqlaTable
|
||||||
from superset.explore.utils import check_datasource_access
|
from superset.explore.utils import check_datasource_access
|
||||||
from superset.models.sql_lab import Query
|
from superset.models.sql_lab import Query
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from collections.abc import Iterator
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.engine import create_engine
|
from sqlalchemy.engine import create_engine
|
||||||
from sqlalchemy.exc import ProgrammingError
|
from sqlalchemy.exc import ProgrammingError
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
@ -105,7 +105,7 @@ def table2(session: Session, database2: "Database") -> Iterator[None]:
|
||||||
|
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_superset(mocker: MockFixture, app_context: None, table1: None) -> None:
|
def test_superset(mocker: MockerFixture, app_context: None, table1: None) -> None:
|
||||||
"""
|
"""
|
||||||
Simple test querying a table.
|
Simple test querying a table.
|
||||||
"""
|
"""
|
||||||
|
|
@ -118,7 +118,7 @@ def test_superset(mocker: MockFixture, app_context: None, table1: None) -> None:
|
||||||
|
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_superset_limit(mocker: MockFixture, app_context: None, table1: None) -> None:
|
def test_superset_limit(mocker: MockerFixture, app_context: None, table1: None) -> None:
|
||||||
"""
|
"""
|
||||||
Simple that limit is applied when querying a table.
|
Simple that limit is applied when querying a table.
|
||||||
"""
|
"""
|
||||||
|
|
@ -140,7 +140,7 @@ def test_superset_limit(mocker: MockFixture, app_context: None, table1: None) ->
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_superset_joins(
|
def test_superset_joins(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
table1: None,
|
table1: None,
|
||||||
table2: None,
|
table2: None,
|
||||||
|
|
@ -165,7 +165,7 @@ def test_superset_joins(
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_dml(
|
def test_dml(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
table1: None,
|
table1: None,
|
||||||
table2: None,
|
table2: None,
|
||||||
|
|
@ -201,7 +201,9 @@ def test_dml(
|
||||||
|
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_security_manager(mocker: MockFixture, app_context: None, table1: None) -> None:
|
def test_security_manager(
|
||||||
|
mocker: MockerFixture, app_context: None, table1: None
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test that we use the security manager to check for permissions.
|
Test that we use the security manager to check for permissions.
|
||||||
"""
|
"""
|
||||||
|
|
@ -232,7 +234,7 @@ def test_security_manager(mocker: MockFixture, app_context: None, table1: None)
|
||||||
|
|
||||||
|
|
||||||
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
@with_feature_flags(ENABLE_SUPERSET_META_DB=True)
|
||||||
def test_allowed_dbs(mocker: MockFixture, app_context: None, table1: None) -> None:
|
def test_allowed_dbs(mocker: MockerFixture, app_context: None, table1: None) -> None:
|
||||||
"""
|
"""
|
||||||
Test that DBs can be restricted.
|
Test that DBs can be restricted.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset import is_feature_enabled
|
from superset import is_feature_enabled
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ def dummy_is_feature_enabled(feature_flag_name: str, default: bool = True) -> bo
|
||||||
return True if feature_flag_name.startswith("True_") else default
|
return True if feature_flag_name.startswith("True_") else default
|
||||||
|
|
||||||
|
|
||||||
def test_existing_feature_flags(mocker: MockFixture) -> None:
|
def test_existing_feature_flags(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test that ``is_feature_enabled`` reads flags correctly.
|
Test that ``is_feature_enabled`` reads flags correctly.
|
||||||
"""
|
"""
|
||||||
|
|
@ -35,7 +35,7 @@ def test_existing_feature_flags(mocker: MockFixture) -> None:
|
||||||
assert is_feature_enabled("FOO") is True
|
assert is_feature_enabled("FOO") is True
|
||||||
|
|
||||||
|
|
||||||
def test_nonexistent_feature_flags(mocker: MockFixture) -> None:
|
def test_nonexistent_feature_flags(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test that ``is_feature_enabled`` returns ``False`` when flag not set.
|
Test that ``is_feature_enabled`` returns ``False`` when flag not set.
|
||||||
"""
|
"""
|
||||||
|
|
@ -45,7 +45,7 @@ def test_nonexistent_feature_flags(mocker: MockFixture) -> None:
|
||||||
assert is_feature_enabled("FOO") is False
|
assert is_feature_enabled("FOO") is False
|
||||||
|
|
||||||
|
|
||||||
def test_is_feature_enabled(mocker: MockFixture) -> None:
|
def test_is_feature_enabled(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test ``_is_feature_enabled_func``.
|
Test ``_is_feature_enabled_func``.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@ from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from zipfile import is_zipfile, ZipFile
|
from zipfile import is_zipfile, ZipFile
|
||||||
|
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset import security_manager
|
from superset import security_manager
|
||||||
from superset.utils import json
|
from superset.utils import json
|
||||||
|
|
||||||
|
|
||||||
def test_export_assets(
|
def test_export_assets(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -69,7 +69,7 @@ def test_export_assets(
|
||||||
|
|
||||||
|
|
||||||
def test_import_assets(
|
def test_import_assets(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -116,7 +116,7 @@ def test_import_assets(
|
||||||
|
|
||||||
|
|
||||||
def test_import_assets_not_zip(
|
def test_import_assets_not_zip(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -154,7 +154,7 @@ def test_import_assets_not_zip(
|
||||||
|
|
||||||
|
|
||||||
def test_import_assets_no_form_data(
|
def test_import_assets_no_form_data(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -188,7 +188,7 @@ def test_import_assets_no_form_data(
|
||||||
|
|
||||||
|
|
||||||
def test_import_assets_incorrect_form_data(
|
def test_import_assets_incorrect_form_data(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -207,7 +207,7 @@ def test_import_assets_incorrect_form_data(
|
||||||
|
|
||||||
|
|
||||||
def test_import_assets_no_contents(
|
def test_import_assets_no_contents(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
client: Any,
|
client: Any,
|
||||||
full_api_access: None,
|
full_api_access: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
from sqlalchemy.dialects.postgresql import dialect
|
from sqlalchemy.dialects.postgresql import dialect
|
||||||
|
|
||||||
|
|
@ -346,7 +346,7 @@ def test_safe_proxy_nested_lambda() -> None:
|
||||||
safe_proxy(func, {"foo": lambda: "bar"})
|
safe_proxy(func, {"foo": lambda: "bar"})
|
||||||
|
|
||||||
|
|
||||||
def test_user_macros(mocker: MockFixture):
|
def test_user_macros(mocker: MockerFixture):
|
||||||
"""
|
"""
|
||||||
Test all user macros:
|
Test all user macros:
|
||||||
- ``current_user_id``
|
- ``current_user_id``
|
||||||
|
|
@ -367,7 +367,7 @@ def test_user_macros(mocker: MockFixture):
|
||||||
assert mock_cache_key_wrapper.call_count == 3
|
assert mock_cache_key_wrapper.call_count == 3
|
||||||
|
|
||||||
|
|
||||||
def test_user_macros_without_cache_key_inclusion(mocker: MockFixture):
|
def test_user_macros_without_cache_key_inclusion(mocker: MockerFixture):
|
||||||
"""
|
"""
|
||||||
Test all user macros with ``add_to_cache_keys`` set to ``False``.
|
Test all user macros with ``add_to_cache_keys`` set to ``False``.
|
||||||
"""
|
"""
|
||||||
|
|
@ -385,7 +385,7 @@ def test_user_macros_without_cache_key_inclusion(mocker: MockFixture):
|
||||||
assert mock_cache_key_wrapper.call_count == 0
|
assert mock_cache_key_wrapper.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
def test_user_macros_without_user_info(mocker: MockFixture):
|
def test_user_macros_without_user_info(mocker: MockerFixture):
|
||||||
"""
|
"""
|
||||||
Test all user macros when no user info is available.
|
Test all user macros when no user info is available.
|
||||||
"""
|
"""
|
||||||
|
|
@ -410,7 +410,7 @@ def test_where_in() -> None:
|
||||||
assert where_in(["O'Malley's"]) == "('O''Malley''s')"
|
assert where_in(["O'Malley's"]) == "('O''Malley''s')"
|
||||||
|
|
||||||
|
|
||||||
def test_dataset_macro(mocker: MockFixture) -> None:
|
def test_dataset_macro(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``dataset_macro`` macro.
|
Test the ``dataset_macro`` macro.
|
||||||
"""
|
"""
|
||||||
|
|
@ -526,7 +526,7 @@ GROUP BY
|
||||||
assert str(excinfo.value) == "Dataset 1 not found!"
|
assert str(excinfo.value) == "Dataset 1 not found!"
|
||||||
|
|
||||||
|
|
||||||
def test_dataset_macro_mutator_with_comments(mocker: MockFixture) -> None:
|
def test_dataset_macro_mutator_with_comments(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test ``dataset_macro`` when the mutator adds comment.
|
Test ``dataset_macro`` when the mutator adds comment.
|
||||||
"""
|
"""
|
||||||
|
|
@ -549,7 +549,7 @@ SELECT 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_with_dataset_id(mocker: MockFixture) -> None:
|
def test_metric_macro_with_dataset_id(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when passing a dataset ID.
|
Test the ``metric_macro`` when passing a dataset ID.
|
||||||
"""
|
"""
|
||||||
|
|
@ -568,7 +568,7 @@ def test_metric_macro_with_dataset_id(mocker: MockFixture) -> None:
|
||||||
mock_get_form_data.assert_not_called()
|
mock_get_form_data.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_with_dataset_id_invalid_key(mocker: MockFixture) -> None:
|
def test_metric_macro_with_dataset_id_invalid_key(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when passing a dataset ID and an invalid key.
|
Test the ``metric_macro`` when passing a dataset ID and an invalid key.
|
||||||
"""
|
"""
|
||||||
|
|
@ -589,7 +589,7 @@ def test_metric_macro_with_dataset_id_invalid_key(mocker: MockFixture) -> None:
|
||||||
mock_get_form_data.assert_not_called()
|
mock_get_form_data.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_invalid_dataset_id(mocker: MockFixture) -> None:
|
def test_metric_macro_invalid_dataset_id(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when specifying a dataset that doesn't exist.
|
Test the ``metric_macro`` when specifying a dataset that doesn't exist.
|
||||||
"""
|
"""
|
||||||
|
|
@ -602,7 +602,7 @@ def test_metric_macro_invalid_dataset_id(mocker: MockFixture) -> None:
|
||||||
mock_get_form_data.assert_not_called()
|
mock_get_form_data.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_no_context(mocker: MockFixture) -> None:
|
def test_metric_macro_no_dataset_id_no_context(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
||||||
not available in the context.
|
not available in the context.
|
||||||
|
|
@ -620,7 +620,7 @@ def test_metric_macro_no_dataset_id_no_context(mocker: MockFixture) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_missing_info(
|
def test_metric_macro_no_dataset_id_with_context_missing_info(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and request
|
Test the ``metric_macro`` when not specifying a dataset ID and request
|
||||||
|
|
@ -644,7 +644,7 @@ def test_metric_macro_no_dataset_id_with_context_missing_info(
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_datasource_id(
|
def test_metric_macro_no_dataset_id_with_context_datasource_id(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
||||||
|
|
@ -675,7 +675,7 @@ def test_metric_macro_no_dataset_id_with_context_datasource_id(
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_datasource_id_none(
|
def test_metric_macro_no_dataset_id_with_context_datasource_id_none(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
Test the ``metric_macro`` when not specifying a dataset ID and it's
|
||||||
|
|
@ -703,7 +703,9 @@ def test_metric_macro_no_dataset_id_with_context_datasource_id_none(
|
||||||
DatasetDAO.find_by_id.assert_not_called()
|
DatasetDAO.find_by_id.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_chart_id(mocker: MockFixture) -> None:
|
def test_metric_macro_no_dataset_id_with_context_chart_id(
|
||||||
|
mocker: MockerFixture,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and context
|
Test the ``metric_macro`` when not specifying a dataset ID and context
|
||||||
includes an existing chart ID (url_params.slice_id).
|
includes an existing chart ID (url_params.slice_id).
|
||||||
|
|
@ -735,7 +737,7 @@ def test_metric_macro_no_dataset_id_with_context_chart_id(mocker: MockFixture) -
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_slice_id_none(
|
def test_metric_macro_no_dataset_id_with_context_slice_id_none(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and context
|
Test the ``metric_macro`` when not specifying a dataset ID and context
|
||||||
|
|
@ -761,7 +763,7 @@ def test_metric_macro_no_dataset_id_with_context_slice_id_none(
|
||||||
DatasetDAO.find_by_id.assert_not_called()
|
DatasetDAO.find_by_id.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_chart(mocker: MockFixture) -> None:
|
def test_metric_macro_no_dataset_id_with_context_chart(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and context
|
Test the ``metric_macro`` when not specifying a dataset ID and context
|
||||||
includes an existing chart (get_form_data()[1]).
|
includes an existing chart (get_form_data()[1]).
|
||||||
|
|
@ -791,7 +793,7 @@ def test_metric_macro_no_dataset_id_with_context_chart(mocker: MockFixture) -> N
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_deleted_chart(
|
def test_metric_macro_no_dataset_id_with_context_deleted_chart(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and context
|
Test the ``metric_macro`` when not specifying a dataset ID and context
|
||||||
|
|
@ -818,7 +820,7 @@ def test_metric_macro_no_dataset_id_with_context_deleted_chart(
|
||||||
|
|
||||||
|
|
||||||
def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id(
|
def test_metric_macro_no_dataset_id_with_context_chart_no_datasource_id(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Test the ``metric_macro`` when not specifying a dataset ID and context
|
Test the ``metric_macro`` when not specifying a dataset ID and context
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.engine.reflection import Inspector
|
from sqlalchemy.engine.reflection import Inspector
|
||||||
from sqlalchemy.engine.url import make_url
|
from sqlalchemy.engine.url import make_url
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ oauth2_client_info = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_get_metrics(mocker: MockFixture) -> None:
|
def test_get_metrics(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Tests for ``get_metrics``.
|
Tests for ``get_metrics``.
|
||||||
"""
|
"""
|
||||||
|
|
@ -89,7 +89,7 @@ def test_get_metrics(mocker: MockFixture) -> None:
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_get_db_engine_spec(mocker: MockFixture) -> None:
|
def test_get_db_engine_spec(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Tests for ``get_db_engine_spec``.
|
Tests for ``get_db_engine_spec``.
|
||||||
"""
|
"""
|
||||||
|
|
@ -228,7 +228,7 @@ def test_table_column_database() -> None:
|
||||||
assert TableColumn(database=database).database is database
|
assert TableColumn(database=database).database is database
|
||||||
|
|
||||||
|
|
||||||
def test_get_prequeries(mocker: MockFixture) -> None:
|
def test_get_prequeries(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Tests for ``get_prequeries``.
|
Tests for ``get_prequeries``.
|
||||||
"""
|
"""
|
||||||
|
|
@ -272,7 +272,7 @@ def test_get_default_catalog() -> None:
|
||||||
assert database.get_default_catalog() == "examples"
|
assert database.get_default_catalog() == "examples"
|
||||||
|
|
||||||
|
|
||||||
def test_get_default_schema(mocker: MockFixture) -> None:
|
def test_get_default_schema(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the `get_default_schema` method.
|
Test the `get_default_schema` method.
|
||||||
"""
|
"""
|
||||||
|
|
@ -289,7 +289,7 @@ def test_get_default_schema(mocker: MockFixture) -> None:
|
||||||
get_inspector.assert_called_with(catalog="examples")
|
get_inspector.assert_called_with(catalog="examples")
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_catalog_names(mocker: MockFixture) -> None:
|
def test_get_all_catalog_names(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the `get_all_catalog_names` method.
|
Test the `get_all_catalog_names` method.
|
||||||
"""
|
"""
|
||||||
|
|
@ -306,7 +306,7 @@ def test_get_all_catalog_names(mocker: MockFixture) -> None:
|
||||||
get_inspector.assert_called_with(ssh_tunnel=None)
|
get_inspector.assert_called_with(ssh_tunnel=None)
|
||||||
|
|
||||||
|
|
||||||
def test_get_sqla_engine(mocker: MockFixture) -> None:
|
def test_get_sqla_engine(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test `_get_sqla_engine`.
|
Test `_get_sqla_engine`.
|
||||||
"""
|
"""
|
||||||
|
|
@ -334,7 +334,7 @@ def test_get_sqla_engine(mocker: MockFixture) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_sqla_engine_user_impersonation(mocker: MockFixture) -> None:
|
def test_get_sqla_engine_user_impersonation(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test user impersonation in `_get_sqla_engine`.
|
Test user impersonation in `_get_sqla_engine`.
|
||||||
"""
|
"""
|
||||||
|
|
@ -364,7 +364,7 @@ def test_get_sqla_engine_user_impersonation(mocker: MockFixture) -> None:
|
||||||
|
|
||||||
|
|
||||||
@with_feature_flags(IMPERSONATE_WITH_EMAIL_PREFIX=True)
|
@with_feature_flags(IMPERSONATE_WITH_EMAIL_PREFIX=True)
|
||||||
def test_get_sqla_engine_user_impersonation_email(mocker: MockFixture) -> None:
|
def test_get_sqla_engine_user_impersonation_email(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test user impersonation in `_get_sqla_engine` with `username_from_email`.
|
Test user impersonation in `_get_sqla_engine` with `username_from_email`.
|
||||||
"""
|
"""
|
||||||
|
|
@ -430,7 +430,7 @@ def test_get_oauth2_config(app_context: None) -> None:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_raw_connection_oauth(mocker: MockFixture) -> None:
|
def test_raw_connection_oauth(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test that we can start OAuth2 from `raw_connection()` errors.
|
Test that we can start OAuth2 from `raw_connection()` errors.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from unittest.mock import MagicMock
|
||||||
import pytest
|
import pytest
|
||||||
from flask_appbuilder import Model
|
from flask_appbuilder import Model
|
||||||
from jinja2.exceptions import TemplateError
|
from jinja2.exceptions import TemplateError
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
||||||
from superset.exceptions import SupersetSecurityException
|
from superset.exceptions import SupersetSecurityException
|
||||||
|
|
@ -49,7 +49,7 @@ from superset.models.sql_lab import Query, SavedQuery
|
||||||
def test_sql_tables_mixin_sql_tables_exception(
|
def test_sql_tables_mixin_sql_tables_exception(
|
||||||
klass: type[Model],
|
klass: type[Model],
|
||||||
exception: Exception,
|
exception: Exception,
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
"superset.models.sql_lab.extract_tables_from_jinja_sql",
|
"superset.models.sql_lab.extract_tables_from_jinja_sql",
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from marshmallow import ValidationError
|
from marshmallow import ValidationError
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.reports.schemas import ReportSchedulePostSchema
|
from superset.reports.schemas import ReportSchedulePostSchema
|
||||||
|
|
||||||
|
|
||||||
def test_report_post_schema_custom_width_validation(mocker: MockFixture) -> None:
|
def test_report_post_schema_custom_width_validation(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the custom width validation.
|
Test the custom width validation.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask_appbuilder.security.sqla.models import Role, User
|
from flask_appbuilder.security.sqla.models import Role, User
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from superset.common.query_object import QueryObject
|
from superset.common.query_object import QueryObject
|
||||||
from superset.connectors.sqla.models import Database, SqlaTable
|
from superset.connectors.sqla.models import Database, SqlaTable
|
||||||
|
|
@ -60,7 +60,7 @@ def stored_metrics() -> list[AdhocMetric]:
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_guest_user_ok(
|
def test_raise_for_access_guest_user_ok(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -87,7 +87,7 @@ def test_raise_for_access_guest_user_ok(
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_guest_user_tampered_id(
|
def test_raise_for_access_guest_user_tampered_id(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -115,7 +115,7 @@ def test_raise_for_access_guest_user_tampered_id(
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_guest_user_tampered_form_data(
|
def test_raise_for_access_guest_user_tampered_form_data(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -152,7 +152,7 @@ def test_raise_for_access_guest_user_tampered_form_data(
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_guest_user_tampered_queries(
|
def test_raise_for_access_guest_user_tampered_queries(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -190,7 +190,7 @@ def test_raise_for_access_guest_user_tampered_queries(
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_query_default_schema(
|
def test_raise_for_access_query_default_schema(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -250,7 +250,7 @@ def test_raise_for_access_query_default_schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_jinja_sql(mocker: MockFixture, app_context: None) -> None:
|
def test_raise_for_access_jinja_sql(mocker: MockerFixture, app_context: None) -> None:
|
||||||
"""
|
"""
|
||||||
Test that Jinja gets rendered to SQL.
|
Test that Jinja gets rendered to SQL.
|
||||||
"""
|
"""
|
||||||
|
|
@ -286,7 +286,7 @@ def test_raise_for_access_jinja_sql(mocker: MockFixture, app_context: None) -> N
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_chart_for_datasource_permission(
|
def test_raise_for_access_chart_for_datasource_permission(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -422,7 +422,7 @@ def test_raise_for_access_chart_owner(
|
||||||
|
|
||||||
|
|
||||||
def test_query_context_modified(
|
def test_query_context_modified(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -448,7 +448,7 @@ def test_query_context_modified(
|
||||||
|
|
||||||
|
|
||||||
def test_query_context_modified_tampered(
|
def test_query_context_modified_tampered(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
stored_metrics: list[AdhocMetric],
|
stored_metrics: list[AdhocMetric],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -483,7 +483,7 @@ def test_query_context_modified_tampered(
|
||||||
assert query_context_modified(query_context)
|
assert query_context_modified(query_context)
|
||||||
|
|
||||||
|
|
||||||
def test_query_context_modified_native_filter(mocker: MockFixture) -> None:
|
def test_query_context_modified_native_filter(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the `query_context_modified` function with a native filter request.
|
Test the `query_context_modified` function with a native filter request.
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ def test_query_context_modified_native_filter(mocker: MockFixture) -> None:
|
||||||
assert not query_context_modified(query_context)
|
assert not query_context_modified(query_context)
|
||||||
|
|
||||||
|
|
||||||
def test_query_context_modified_mixed_chart(mocker: MockFixture) -> None:
|
def test_query_context_modified_mixed_chart(mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
Test the `query_context_modified` function for a mixed chart request.
|
Test the `query_context_modified` function for a mixed chart request.
|
||||||
|
|
||||||
|
|
@ -564,7 +564,7 @@ def test_get_schema_perm() -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_raise_for_access_catalog(
|
def test_raise_for_access_catalog(
|
||||||
mocker: MockFixture,
|
mocker: MockerFixture,
|
||||||
app_context: None,
|
app_context: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
|
|
@ -67,7 +67,7 @@ def session_with_data(session: Session):
|
||||||
yield session
|
yield session
|
||||||
|
|
||||||
|
|
||||||
def test_create_command_success(session_with_data: Session, mocker: MockFixture):
|
def test_create_command_success(session_with_data: Session, mocker: MockerFixture):
|
||||||
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
||||||
from superset.models.dashboard import Dashboard
|
from superset.models.dashboard import Dashboard
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
@ -108,7 +108,9 @@ def test_create_command_success(session_with_data: Session, mocker: MockFixture)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_create_command_success_clear(session_with_data: Session, mocker: MockFixture):
|
def test_create_command_success_clear(
|
||||||
|
session_with_data: Session, mocker: MockerFixture
|
||||||
|
):
|
||||||
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
||||||
from superset.models.dashboard import Dashboard
|
from superset.models.dashboard import Dashboard
|
||||||
from superset.models.slice import Slice
|
from superset.models.slice import Slice
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockerFixture
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from superset import db
|
from superset import db
|
||||||
|
|
@ -76,7 +76,7 @@ def session_with_data(session: Session):
|
||||||
yield session
|
yield session
|
||||||
|
|
||||||
|
|
||||||
def test_update_command_success(session_with_data: Session, mocker: MockFixture):
|
def test_update_command_success(session_with_data: Session, mocker: MockerFixture):
|
||||||
from superset.commands.tag.update import UpdateTagCommand
|
from superset.commands.tag.update import UpdateTagCommand
|
||||||
from superset.daos.tag import TagDAO
|
from superset.daos.tag import TagDAO
|
||||||
from superset.models.dashboard import Dashboard
|
from superset.models.dashboard import Dashboard
|
||||||
|
|
@ -111,7 +111,7 @@ def test_update_command_success(session_with_data: Session, mocker: MockFixture)
|
||||||
|
|
||||||
|
|
||||||
def test_update_command_success_duplicates(
|
def test_update_command_success_duplicates(
|
||||||
session_with_data: Session, mocker: MockFixture
|
session_with_data: Session, mocker: MockerFixture
|
||||||
):
|
):
|
||||||
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
||||||
from superset.commands.tag.update import UpdateTagCommand
|
from superset.commands.tag.update import UpdateTagCommand
|
||||||
|
|
@ -161,7 +161,7 @@ def test_update_command_success_duplicates(
|
||||||
|
|
||||||
|
|
||||||
def test_update_command_failed_validation(
|
def test_update_command_failed_validation(
|
||||||
session_with_data: Session, mocker: MockFixture
|
session_with_data: Session, mocker: MockerFixture
|
||||||
):
|
):
|
||||||
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
from superset.commands.tag.create import CreateCustomTagWithRelationshipsCommand
|
||||||
from superset.commands.tag.exceptions import TagInvalidError
|
from superset.commands.tag.exceptions import TagInvalidError
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue