feat: Switch from nosetest to pytest (#10177)
* Switch from nosetest to pytest Fix schedule tests Collect pytest coverage Move pytest config into pytest.ini Move cov to the pytest.ini * Append coverage for the 2nd run * Add coverage to all commands * Coverage only for tests * Get coverage from 1 place * Rename classes to be pytest compatible * Test coverage for examples and tests * Max diff to -1 * Explain how to run pytest for the whole project * Do not append code coverage for the main run * Do not run coverage on examples Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
parent
72fc581b15
commit
4e340c8368
|
|
@ -0,0 +1,21 @@
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
[pytest]
|
||||||
|
addopts = -ra -q
|
||||||
|
testpaths =
|
||||||
|
tests
|
||||||
|
python_files = *_test.py test_*.py *_tests.py
|
||||||
|
|
@ -21,7 +21,8 @@ flask-testing==0.8.0
|
||||||
ipdb==0.12
|
ipdb==0.12
|
||||||
isort==4.3.21
|
isort==4.3.21
|
||||||
mypy==0.770
|
mypy==0.770
|
||||||
nose==1.3.7
|
pytest==5.4.3
|
||||||
|
pytest-cov==2.10.0
|
||||||
parameterized==0.7.4
|
parameterized==0.7.4
|
||||||
pip-tools==5.1.2
|
pip-tools==5.1.2
|
||||||
pre-commit==1.17.0
|
pre-commit==1.17.0
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,5 @@ echo "Superset config module: $SUPERSET_CONFIG"
|
||||||
|
|
||||||
superset db upgrade
|
superset db upgrade
|
||||||
superset init
|
superset init
|
||||||
nosetests --stop tests/load_examples_test.py
|
pytest --maxfail=1 tests/load_examples_test.py
|
||||||
nosetests --stop --exclude=load_examples_test tests
|
pytest --maxfail=1 --cov=superset --ignore=load_examples_test tests/*
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ function test_init() {
|
||||||
echo --------------------
|
echo --------------------
|
||||||
echo Load examples
|
echo Load examples
|
||||||
echo --------------------
|
echo --------------------
|
||||||
nosetests tests/load_examples_test.py
|
pytest -s tests/load_examples_test.py
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -145,5 +145,5 @@ fi
|
||||||
|
|
||||||
if [ $RUN_TESTS -eq 1 ]
|
if [ $RUN_TESTS -eq 1 ]
|
||||||
then
|
then
|
||||||
nosetests --exclude=load_examples_test "${TEST_MODULE}"
|
pytest -s --ignore=load_examples_test "${TEST_MODULE}"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,6 @@ all_files = 1
|
||||||
[upload_sphinx]
|
[upload_sphinx]
|
||||||
upload-dir = docs/_build/html
|
upload-dir = docs/_build/html
|
||||||
|
|
||||||
[nosetests]
|
|
||||||
verbosity = 3
|
|
||||||
detailed-errors = 1
|
|
||||||
with-coverage = 1
|
|
||||||
nocapture = 1
|
|
||||||
cover-package = superset
|
|
||||||
|
|
||||||
[isort]
|
[isort]
|
||||||
combine_as_imports = true
|
combine_as_imports = true
|
||||||
include_trailing_comma = true
|
include_trailing_comma = true
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,12 @@ def create_access_request(session, ds_type, ds_name, role_name, user_name):
|
||||||
return access_request
|
return access_request
|
||||||
|
|
||||||
|
|
||||||
class RequestAccessTests(SupersetTestCase):
|
class TestRequestAccess(SupersetTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
cls.create_druid_test_objects()
|
||||||
|
|
||||||
security_manager.add_role("override_me")
|
security_manager.add_role("override_me")
|
||||||
security_manager.add_role(TEST_ROLE_1)
|
security_manager.add_role(TEST_ROLE_1)
|
||||||
security_manager.add_role(TEST_ROLE_2)
|
security_manager.add_role(TEST_ROLE_2)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Model1Api(BaseSupersetModelRestApi):
|
||||||
appbuilder.add_api(Model1Api)
|
appbuilder.add_api(Model1Api)
|
||||||
|
|
||||||
|
|
||||||
class BaseModelRestApiTests(SupersetTestCase):
|
class TestBaseModelRestApi(SupersetTestCase):
|
||||||
def test_default_missing_declaration_get(self):
|
def test_default_missing_declaration_get(self):
|
||||||
"""
|
"""
|
||||||
API: Test default missing declaration on get
|
API: Test default missing declaration on get
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,7 @@ class SupersetTestCase(TestCase):
|
||||||
"postgresql": "public",
|
"postgresql": "public",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
maxDiff = -1
|
||||||
super(SupersetTestCase, self).__init__(*args, **kwargs)
|
|
||||||
self.maxDiff = None
|
|
||||||
|
|
||||||
def create_app(self):
|
def create_app(self):
|
||||||
return app
|
return app
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,7 @@ from superset.utils.core import QueryStatus
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class CacheTests(SupersetTestCase):
|
class TestCache(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(CacheTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache.clear()
|
cache.clear()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ CELERY_SLEEP_TIME = 10
|
||||||
DROP_TABLE_SLEEP_TIME = 10
|
DROP_TABLE_SLEEP_TIME = 10
|
||||||
|
|
||||||
|
|
||||||
class UtilityFunctionTests(SupersetTestCase):
|
class TestUtilityFunction(SupersetTestCase):
|
||||||
# TODO(bkyryliuk): support more cases in CTA function.
|
# TODO(bkyryliuk): support more cases in CTA function.
|
||||||
def test_create_table_as(self):
|
def test_create_table_as(self):
|
||||||
q = ParsedQuery("SELECT * FROM outer_space;")
|
q = ParsedQuery("SELECT * FROM outer_space;")
|
||||||
|
|
@ -75,7 +75,7 @@ class UtilityFunctionTests(SupersetTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AppContextTests(SupersetTestCase):
|
class TestAppContext(SupersetTestCase):
|
||||||
def test_in_app_context(self):
|
def test_in_app_context(self):
|
||||||
@celery_app.task()
|
@celery_app.task()
|
||||||
def my_task():
|
def my_task():
|
||||||
|
|
@ -95,7 +95,7 @@ class AppContextTests(SupersetTestCase):
|
||||||
CTAS_SCHEMA_NAME = "sqllab_test_db"
|
CTAS_SCHEMA_NAME = "sqllab_test_db"
|
||||||
|
|
||||||
|
|
||||||
class CeleryTestCase(SupersetTestCase):
|
class TestCelery(SupersetTestCase):
|
||||||
def get_query_by_name(self, sql):
|
def get_query_by_name(self, sql):
|
||||||
session = db.session
|
session = db.session
|
||||||
query = session.query(Query).filter_by(sql=sql).first()
|
query = session.query(Query).filter_by(sql=sql).first()
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,9 @@ from tests.fixtures.query_context import get_query_context
|
||||||
CHART_DATA_URI = "api/v1/chart/data"
|
CHART_DATA_URI = "api/v1/chart/data"
|
||||||
|
|
||||||
|
|
||||||
class ChartApiTests(SupersetTestCase, ApiOwnersTestCaseMixin):
|
class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin):
|
||||||
resource_name = "chart"
|
resource_name = "chart"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(ChartApiTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def insert_chart(
|
def insert_chart(
|
||||||
self,
|
self,
|
||||||
slice_name: str,
|
slice_name: str,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ def load_query_context(payload: Dict[str, Any]) -> Tuple[QueryContext, Dict[str,
|
||||||
return ChartDataQueryContextSchema().load(payload)
|
return ChartDataQueryContextSchema().load(payload)
|
||||||
|
|
||||||
|
|
||||||
class SchemaTestCase(SupersetTestCase):
|
class TestSchema(SupersetTestCase):
|
||||||
def test_query_context_limit_and_offset(self):
|
def test_query_context_limit_and_offset(self):
|
||||||
self.login(username="admin")
|
self.login(username="admin")
|
||||||
table_name = "birth_names"
|
table_name = "birth_names"
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,7 @@ def apply_dttm_defaults(table: SqlaTable, dttm_defaults: Dict[str, Any]):
|
||||||
dbcol.expression = dttm_column_defaults["expression"]
|
dbcol.expression = dttm_column_defaults["expression"]
|
||||||
|
|
||||||
|
|
||||||
class ConfigTests(SupersetTestCase):
|
class TestConfig(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(ConfigTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.login(username="admin")
|
self.login(username="admin")
|
||||||
self._test_db_id = get_or_create_db(
|
self._test_db_id = get_or_create_db(
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,7 @@ from .base_tests import SupersetTestCase
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CoreTests(SupersetTestCase):
|
class TestCore(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(CoreTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
db.session.query(Query).delete()
|
db.session.query(Query).delete()
|
||||||
db.session.query(DatasourceAccessRequest).delete()
|
db.session.query(DatasourceAccessRequest).delete()
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ from superset.views import core as views
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DashboardTests(SupersetTestCase):
|
class TestDashboard(SupersetTestCase):
|
||||||
def get_mock_positions(self, dash):
|
def get_mock_positions(self, dash):
|
||||||
positions = {"DASHBOARD_VERSION_KEY": "v2"}
|
positions = {"DASHBOARD_VERSION_KEY": "v2"}
|
||||||
for i, slc in enumerate(dash.slices):
|
for i, slc in enumerate(dash.slices):
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ from tests.base_api_tests import ApiOwnersTestCaseMixin
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DashboardApiTests(SupersetTestCase, ApiOwnersTestCaseMixin):
|
class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin):
|
||||||
resource_name = "dashboard"
|
resource_name = "dashboard"
|
||||||
|
|
||||||
dashboard_data = {
|
dashboard_data = {
|
||||||
|
|
@ -44,9 +44,6 @@ class DashboardApiTests(SupersetTestCase, ApiOwnersTestCaseMixin):
|
||||||
"published": False,
|
"published": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(DashboardApiTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def insert_dashboard(
|
def insert_dashboard(
|
||||||
self,
|
self,
|
||||||
dashboard_title: str,
|
dashboard_title: str,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from superset.models.dashboard import Dashboard
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DashboardDAOTests(SupersetTestCase):
|
class TestDashboardDAO(SupersetTestCase):
|
||||||
def test_set_dash_metadata(self):
|
def test_set_dash_metadata(self):
|
||||||
dash = db.session.query(Dashboard).filter_by(slug="world_health").first()
|
dash = db.session.query(Dashboard).filter_by(slug="world_health").first()
|
||||||
data = dash.data
|
data = dash.data
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ from superset.utils.core import get_example_database
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DatabaseApiTests(SupersetTestCase):
|
class TestDatabaseApi(SupersetTestCase):
|
||||||
def test_get_items(self):
|
def test_get_items(self):
|
||||||
"""
|
"""
|
||||||
Database API: Test get items
|
Database API: Test get items
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ from superset.result_set import SupersetResultSet
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class SupersetDataFrameTestCase(SupersetTestCase):
|
class TestSupersetDataFrame(SupersetTestCase):
|
||||||
def test_df_to_records(self):
|
def test_df_to_records(self):
|
||||||
data = [("a1", "b1", "c1"), ("a2", "b2", "c2")]
|
data = [("a1", "b1", "c1"), ("a2", "b2", "c2")]
|
||||||
cursor_descr = (("a", "string"), ("b", "string"), ("c", "string"))
|
cursor_descr = (("a", "string"), ("b", "string"), ("c", "string"))
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ from superset.views.base import generate_download_headers
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DatasetApiTests(SupersetTestCase):
|
class TestDatasetApi(SupersetTestCase):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def insert_dataset(
|
def insert_dataset(
|
||||||
table_name: str, schema: str, owners: List[int], database: Database
|
table_name: str, schema: str, owners: List[int], database: Database
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,7 @@ from .base_tests import SupersetTestCase
|
||||||
from .fixtures.datasource import datasource_post
|
from .fixtures.datasource import datasource_post
|
||||||
|
|
||||||
|
|
||||||
class DatasourceTests(SupersetTestCase):
|
class TestDatasource(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(DatasourceTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def test_external_metadata(self):
|
def test_external_metadata(self):
|
||||||
self.login(username="admin")
|
self.login(username="admin")
|
||||||
tbl = self.get_table_by_name("birth_names")
|
tbl = self.get_table_by_name("birth_names")
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
from tests.test_app import app # isort:skip
|
from tests.test_app import app # isort:skip
|
||||||
|
|
||||||
from superset.db_engine_specs.athena import AthenaEngineSpec
|
from superset.db_engine_specs.athena import AthenaEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class AthenaTestCase(DbEngineSpecTestCase):
|
class TestAthenaDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ from superset.db_engine_specs import engines
|
||||||
from superset.db_engine_specs.base import BaseEngineSpec, builtin_time_grains
|
from superset.db_engine_specs.base import BaseEngineSpec, builtin_time_grains
|
||||||
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
||||||
from superset.utils.core import get_example_database
|
from superset.utils.core import get_example_database
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
from ..fixtures.pyodbcRow import Row
|
from ..fixtures.pyodbcRow import Row
|
||||||
|
|
||||||
|
|
||||||
class DbEngineSpecsTests(DbEngineSpecTestCase):
|
class TestDbEngineSpecs(TestDbEngineSpec):
|
||||||
def test_extract_limit_from_query(self, engine_spec_class=BaseEngineSpec):
|
def test_extract_limit_from_query(self, engine_spec_class=BaseEngineSpec):
|
||||||
q0 = "select * from table"
|
q0 = "select * from table"
|
||||||
q1 = "select * from mytable limit 10"
|
q1 = "select * from mytable limit 10"
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from tests.base_tests import SupersetTestCase
|
||||||
from tests.test_app import app # isort:skip
|
from tests.test_app import app # isort:skip
|
||||||
|
|
||||||
|
|
||||||
class DbEngineSpecTestCase(SupersetTestCase):
|
class TestDbEngineSpec(SupersetTestCase):
|
||||||
def sql_limit_regex(
|
def sql_limit_regex(
|
||||||
self, sql, expected_sql, engine_spec_class=MySQLEngineSpec, limit=1000
|
self, sql, expected_sql, engine_spec_class=MySQLEngineSpec, limit=1000
|
||||||
):
|
):
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ from sqlalchemy import column
|
||||||
|
|
||||||
from superset.db_engine_specs.base import BaseEngineSpec
|
from superset.db_engine_specs.base import BaseEngineSpec
|
||||||
from superset.db_engine_specs.bigquery import BigQueryEngineSpec
|
from superset.db_engine_specs.bigquery import BigQueryEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class BigQueryTestCase(DbEngineSpecTestCase):
|
class TestBigQueryDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_bigquery_sqla_column_label(self):
|
def test_bigquery_sqla_column_label(self):
|
||||||
"""
|
"""
|
||||||
DB Eng Specs (bigquery): Test column label
|
DB Eng Specs (bigquery): Test column label
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.clickhouse import ClickHouseEngineSpec
|
from superset.db_engine_specs.clickhouse import ClickHouseEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class ClickHouseTestCase(DbEngineSpecTestCase):
|
class TestClickHouseDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.drill import DrillEngineSpec
|
from superset.db_engine_specs.drill import DrillEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class DrillTestCase(DbEngineSpecTestCase):
|
class TestDrillDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
from sqlalchemy import column
|
from sqlalchemy import column
|
||||||
|
|
||||||
from superset.db_engine_specs.druid import DruidEngineSpec
|
from superset.db_engine_specs.druid import DruidEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class DruidTestCase(DbEngineSpecTestCase):
|
class TestDruidDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.elasticsearch import ElasticSearchEngineSpec
|
from superset.db_engine_specs.elasticsearch import ElasticSearchEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class ElasticSearchTestCase(DbEngineSpecTestCase):
|
class TestElasticSearchDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ from unittest import mock
|
||||||
from superset.db_engine_specs.hive import HiveEngineSpec
|
from superset.db_engine_specs.hive import HiveEngineSpec
|
||||||
from superset.exceptions import SupersetException
|
from superset.exceptions import SupersetException
|
||||||
from superset.sql_parse import Table
|
from superset.sql_parse import Table
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class HiveTests(DbEngineSpecTestCase):
|
class TestHiveDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_0_progress(self):
|
def test_0_progress(self):
|
||||||
log = """
|
log = """
|
||||||
17/02/07 18:26:27 INFO log.PerfLogger: <PERFLOG method=compile from=org.apache.hadoop.hive.ql.Driver>
|
17/02/07 18:26:27 INFO log.PerfLogger: <PERFLOG method=compile from=org.apache.hadoop.hive.ql.Driver>
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.impala import ImpalaEngineSpec
|
from superset.db_engine_specs.impala import ImpalaEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class ImpalaTestCase(DbEngineSpecTestCase):
|
class TestImpalaDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.kylin import KylinEngineSpec
|
from superset.db_engine_specs.kylin import KylinEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class KylinTestCase(DbEngineSpecTestCase):
|
class TestKylinDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ from sqlalchemy.types import String, UnicodeText
|
||||||
|
|
||||||
from superset.db_engine_specs.base import BaseEngineSpec
|
from superset.db_engine_specs.base import BaseEngineSpec
|
||||||
from superset.db_engine_specs.mssql import MssqlEngineSpec
|
from superset.db_engine_specs.mssql import MssqlEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class MssqlEngineSpecTest(DbEngineSpecTestCase):
|
class TestMssqlEngineSpec(TestDbEngineSpec):
|
||||||
def test_mssql_column_types(self):
|
def test_mssql_column_types(self):
|
||||||
def assert_type(type_string, type_expected):
|
def assert_type(type_string, type_expected):
|
||||||
type_assigned = MssqlEngineSpec.get_sqla_column_type(type_string)
|
type_assigned = MssqlEngineSpec.get_sqla_column_type(type_string)
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ from sqlalchemy.dialects import mysql
|
||||||
from sqlalchemy.dialects.mysql import DATE, NVARCHAR, TEXT, VARCHAR
|
from sqlalchemy.dialects.mysql import DATE, NVARCHAR, TEXT, VARCHAR
|
||||||
|
|
||||||
from superset.db_engine_specs.mysql import MySQLEngineSpec
|
from superset.db_engine_specs.mysql import MySQLEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class MySQLEngineSpecsTestCase(DbEngineSpecTestCase):
|
class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec):
|
||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
DbEngineSpecTestCase.is_module_installed("MySQLdb"), "mysqlclient not installed"
|
TestDbEngineSpec.is_module_installed("MySQLdb"), "mysqlclient not installed"
|
||||||
)
|
)
|
||||||
def test_get_datatype_mysql(self):
|
def test_get_datatype_mysql(self):
|
||||||
"""Tests related to datatype mapping for MySQL"""
|
"""Tests related to datatype mapping for MySQL"""
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ from sqlalchemy.dialects import oracle
|
||||||
from sqlalchemy.dialects.oracle import DATE, NVARCHAR, VARCHAR
|
from sqlalchemy.dialects.oracle import DATE, NVARCHAR, VARCHAR
|
||||||
|
|
||||||
from superset.db_engine_specs.oracle import OracleEngineSpec
|
from superset.db_engine_specs.oracle import OracleEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class OracleTestCase(DbEngineSpecTestCase):
|
class TestOracleDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_oracle_sqla_column_name_length_exceeded(self):
|
def test_oracle_sqla_column_name_length_exceeded(self):
|
||||||
col = column("This_Is_32_Character_Column_Name")
|
col = column("This_Is_32_Character_Column_Name")
|
||||||
label = OracleEngineSpec.make_label_compatible(col.name)
|
label = OracleEngineSpec.make_label_compatible(col.name)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
from sqlalchemy import column
|
from sqlalchemy import column
|
||||||
|
|
||||||
from superset.db_engine_specs.pinot import PinotEngineSpec
|
from superset.db_engine_specs.pinot import PinotEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class PinotTestCase(DbEngineSpecTestCase):
|
class TestPinotDbEngineSpec(TestDbEngineSpec):
|
||||||
""" Tests pertaining to our Pinot database support """
|
""" Tests pertaining to our Pinot database support """
|
||||||
|
|
||||||
def test_pinot_time_expression_sec_one_1m_grain(self):
|
def test_pinot_time_expression_sec_one_1m_grain(self):
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ from sqlalchemy import column, literal_column
|
||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
from superset.db_engine_specs.postgres import PostgresEngineSpec
|
from superset.db_engine_specs.postgres import PostgresEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class PostgresTests(DbEngineSpecTestCase):
|
class TestPostgresDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_get_table_names(self):
|
def test_get_table_names(self):
|
||||||
"""
|
"""
|
||||||
DB Eng Specs (postgres): Test get table names
|
DB Eng Specs (postgres): Test get table names
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,11 @@ from sqlalchemy.engine.result import RowProxy
|
||||||
from sqlalchemy.sql import select
|
from sqlalchemy.sql import select
|
||||||
|
|
||||||
from superset.db_engine_specs.presto import PrestoEngineSpec
|
from superset.db_engine_specs.presto import PrestoEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class PrestoTests(DbEngineSpecTestCase):
|
class TestPrestoDbEngineSpec(TestDbEngineSpec):
|
||||||
@skipUnless(
|
@skipUnless(TestDbEngineSpec.is_module_installed("pyhive"), "pyhive not installed")
|
||||||
DbEngineSpecTestCase.is_module_installed("pyhive"), "pyhive not installed"
|
|
||||||
)
|
|
||||||
def test_get_datatype_presto(self):
|
def test_get_datatype_presto(self):
|
||||||
self.assertEqual("STRING", PrestoEngineSpec.get_datatype("string"))
|
self.assertEqual("STRING", PrestoEngineSpec.get_datatype("string"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ import json
|
||||||
|
|
||||||
from superset.db_engine_specs.snowflake import SnowflakeEngineSpec
|
from superset.db_engine_specs.snowflake import SnowflakeEngineSpec
|
||||||
from superset.models.core import Database
|
from superset.models.core import Database
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class SnowflakeTestCase(DbEngineSpecTestCase):
|
class TestSnowflakeDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
||||||
from tests.db_engine_specs.base_tests import DbEngineSpecTestCase
|
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||||
|
|
||||||
|
|
||||||
class SQliteTestCase(DbEngineSpecTestCase):
|
class TestSQliteDbEngineSpec(TestDbEngineSpec):
|
||||||
def test_convert_dttm(self):
|
def test_convert_dttm(self):
|
||||||
dttm = self.get_dttm()
|
dttm = self.get_dttm()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,9 @@ NAME_PREFIX = "dict_"
|
||||||
ID_PREFIX = 20000
|
ID_PREFIX = 20000
|
||||||
|
|
||||||
|
|
||||||
class DictImportExportTests(SupersetTestCase):
|
class TestDictImportExport(SupersetTestCase):
|
||||||
"""Testing export import functionality for dashboards"""
|
"""Testing export import functionality for dashboards"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(DictImportExportTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete_imports(cls):
|
def delete_imports(cls):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ def emplace(metrics_dict, metric_name, is_postagg=False):
|
||||||
|
|
||||||
|
|
||||||
# Unit tests that can be run without initializing base tests
|
# Unit tests that can be run without initializing base tests
|
||||||
class DruidFuncTestCase(SupersetTestCase):
|
class TestDruidFunc(SupersetTestCase):
|
||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ def emplace(metrics_dict, metric_name, is_postagg=False):
|
||||||
{"SIP_38_VIZ_REARCHITECTURE": True},
|
{"SIP_38_VIZ_REARCHITECTURE": True},
|
||||||
clear=True,
|
clear=True,
|
||||||
)
|
)
|
||||||
class DruidFuncTestCase(SupersetTestCase):
|
class TestDruidFunc(SupersetTestCase):
|
||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ GB_RESULT_SET = [
|
||||||
DruidCluster.get_druid_version = lambda _: "0.9.1" # type: ignore
|
DruidCluster.get_druid_version = lambda _: "0.9.1" # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class DruidTests(SupersetTestCase):
|
class TestDruid(SupersetTestCase):
|
||||||
|
|
||||||
"""Testing interactions with Druid"""
|
"""Testing interactions with Druid"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ send_email_test = mock.Mock()
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EmailSmtpTest(SupersetTestCase):
|
class TestEmailSmtp(SupersetTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
app.config["smtp_ssl"] = False
|
app.config["smtp_ssl"] = False
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ from superset import is_feature_enabled
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class FeatureFlagTests(SupersetTestCase):
|
class TestFeatureFlag(SupersetTestCase):
|
||||||
@patch.dict(
|
@patch.dict(
|
||||||
"superset.extensions.feature_flag_manager._feature_flags",
|
"superset.extensions.feature_flag_manager._feature_flags",
|
||||||
{"FOO": True},
|
{"FOO": True},
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ from superset.forms import CommaSeparatedListField, filter_not_empty_values
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class FormTestCase(SupersetTestCase):
|
class TestForm(SupersetTestCase):
|
||||||
def test_comma_separated_list_field(self):
|
def test_comma_separated_list_field(self):
|
||||||
field = CommaSeparatedListField().bind(Form(), "foo")
|
field = CommaSeparatedListField().bind(Form(), "foo")
|
||||||
field.process_formdata([u""])
|
field.process_formdata([u""])
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ from superset.models.slice import Slice
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class ImportExportTests(SupersetTestCase):
|
class TestImportExport(SupersetTestCase):
|
||||||
"""Testing export import functionality for dashboards"""
|
"""Testing export import functionality for dashboards"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from superset.jinja_context import ExtraCache, filter_values
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class Jinja2ContextTests(SupersetTestCase):
|
class TestJinja2Context(SupersetTestCase):
|
||||||
def test_filter_values_default(self) -> None:
|
def test_filter_values_default(self) -> None:
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
self.assertEquals(filter_values("name", "foo"), ["foo"])
|
self.assertEquals(filter_values("name", "foo"), ["foo"])
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,7 @@
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class SupersetDataFrameTestCase(SupersetTestCase):
|
class TestSupersetDataFrame(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.examples = None
|
|
||||||
|
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# Late importing here as we need an app context to be pushed...
|
# Late importing here as we need an app context to be pushed...
|
||||||
from superset import examples
|
from superset import examples
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ from superset.models.core import Log
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class LogApiTests(SupersetTestCase):
|
class TestLogApi(SupersetTestCase):
|
||||||
def insert_log(
|
def insert_log(
|
||||||
self,
|
self,
|
||||||
action: str,
|
action: str,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from superset.migrations.versions.fb13d49b72f9_better_filters import (
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class MigrationTestCase(SupersetTestCase):
|
class TestMigration(SupersetTestCase):
|
||||||
def test_upgrade_slice(self):
|
def test_upgrade_slice(self):
|
||||||
slc = Slice(
|
slc = Slice(
|
||||||
slice_name="FOO",
|
slice_name="FOO",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ from superset.utils.core import get_example_database, QueryStatus
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DatabaseModelTestCase(SupersetTestCase):
|
class TestDatabaseModel(SupersetTestCase):
|
||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
SupersetTestCase.is_module_installed("requests"), "requests not installed"
|
SupersetTestCase.is_module_installed("requests"), "requests not installed"
|
||||||
)
|
)
|
||||||
|
|
@ -173,7 +173,7 @@ class DatabaseModelTestCase(SupersetTestCase):
|
||||||
self.assertEqual(df.iat[0, 0], ";")
|
self.assertEqual(df.iat[0, 0], ";")
|
||||||
|
|
||||||
|
|
||||||
class SqlaTableModelTestCase(SupersetTestCase):
|
class TestSqlaTableModel(SupersetTestCase):
|
||||||
def test_get_timestamp_expression(self):
|
def test_get_timestamp_expression(self):
|
||||||
tbl = self.get_table_by_name("birth_names")
|
tbl = self.get_table_by_name("birth_names")
|
||||||
ds_col = tbl.get_column("ds")
|
ds_col = tbl.get_column("ds")
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ def round_floats(
|
||||||
return [round(val, precision) if val else None for val in floats]
|
return [round(val, precision) if val else None for val in floats]
|
||||||
|
|
||||||
|
|
||||||
class PostProcessingTestCase(SupersetTestCase):
|
class TestPostProcessing(SupersetTestCase):
|
||||||
def test_pivot(self):
|
def test_pivot(self):
|
||||||
aggregates = {"idx_nulls": {"operator": "sum"}}
|
aggregates = {"idx_nulls": {"operator": "sum"}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ from superset.models.sql_lab import Query
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class QueryApiTests(SupersetTestCase):
|
class TestQueryApi(SupersetTestCase):
|
||||||
def insert_query(
|
def insert_query(
|
||||||
self,
|
self,
|
||||||
database_id: int,
|
database_id: int,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from tests.base_tests import SupersetTestCase
|
||||||
from tests.fixtures.query_context import get_query_context
|
from tests.fixtures.query_context import get_query_context
|
||||||
|
|
||||||
|
|
||||||
class QueryContextTests(SupersetTestCase):
|
class TestQueryContext(SupersetTestCase):
|
||||||
def test_schema_deserialization(self):
|
def test_schema_deserialization(self):
|
||||||
"""
|
"""
|
||||||
Ensure that the deserialized QueryContext contains all required fields.
|
Ensure that the deserialized QueryContext contains all required fields.
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from superset.result_set import dedup, SupersetResultSet
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class SupersetResultSetTestCase(SupersetTestCase):
|
class TestSupersetResultSet(SupersetTestCase):
|
||||||
def test_dedup(self):
|
def test_dedup(self):
|
||||||
self.assertEqual(dedup(["foo", "bar"]), ["foo", "bar"])
|
self.assertEqual(dedup(["foo", "bar"]), ["foo", "bar"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ from tests.base_tests import SupersetTestCase
|
||||||
from .utils import read_fixture
|
from .utils import read_fixture
|
||||||
|
|
||||||
|
|
||||||
class SchedulesTestCase(SupersetTestCase):
|
class TestSchedules(SupersetTestCase):
|
||||||
|
|
||||||
RECIPIENTS = "recipient1@superset.com, recipient2@superset.com"
|
RECIPIENTS = "recipient1@superset.com, recipient2@superset.com"
|
||||||
BCC = "bcc@superset.com"
|
BCC = "bcc@superset.com"
|
||||||
|
|
@ -379,7 +379,7 @@ class SchedulesTestCase(SupersetTestCase):
|
||||||
{
|
{
|
||||||
"channels": "#test_channel",
|
"channels": "#test_channel",
|
||||||
"file": element.screenshot_as_png,
|
"file": element.screenshot_as_png,
|
||||||
"initial_comment": "\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/1/|Explore in Superset>\n ",
|
"initial_comment": f"\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/{schedule.slice_id}/|Explore in Superset>\n ",
|
||||||
"title": "[Report] Participants",
|
"title": "[Report] Participants",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -434,7 +434,7 @@ class SchedulesTestCase(SupersetTestCase):
|
||||||
{
|
{
|
||||||
"channels": "#test_channel",
|
"channels": "#test_channel",
|
||||||
"file": element.screenshot_as_png,
|
"file": element.screenshot_as_png,
|
||||||
"initial_comment": "\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/1/|Explore in Superset>\n ",
|
"initial_comment": f"\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/{schedule.slice_id}/|Explore in Superset>\n ",
|
||||||
"title": "[Report] Participants",
|
"title": "[Report] Participants",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -481,7 +481,7 @@ class SchedulesTestCase(SupersetTestCase):
|
||||||
{
|
{
|
||||||
"channels": "#test_channel",
|
"channels": "#test_channel",
|
||||||
"file": self.CSV,
|
"file": self.CSV,
|
||||||
"initial_comment": "\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/1/|Explore in Superset>\n ",
|
"initial_comment": f"\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/{schedule.slice_id}/|Explore in Superset>\n ",
|
||||||
"title": "[Report] Participants",
|
"title": "[Report] Participants",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -526,7 +526,7 @@ class SchedulesTestCase(SupersetTestCase):
|
||||||
{
|
{
|
||||||
"channels": "#test_channel",
|
"channels": "#test_channel",
|
||||||
"file": self.CSV,
|
"file": self.CSV,
|
||||||
"initial_comment": "\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/1/|Explore in Superset>\n ",
|
"initial_comment": f"\n *Participants*\n\n <http://0.0.0.0:8080/superset/slice/{schedule.slice_id}/|Explore in Superset>\n ",
|
||||||
"title": "[Report] Participants",
|
"title": "[Report] Participants",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from superset.security.analytics_db_safety import (
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DBConnectionsTest(SupersetTestCase):
|
class TestDBConnections(SupersetTestCase):
|
||||||
def test_check_sqlalchemy_uri_ok(self):
|
def test_check_sqlalchemy_uri_ok(self):
|
||||||
check_sqlalchemy_uri("postgres://user:password@test.com")
|
check_sqlalchemy_uri("postgres://user:password@test.com")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ def delete_schema_perm(view_menu_name: str) -> None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class RolePermissionTests(SupersetTestCase):
|
class TestRolePermission(SupersetTestCase):
|
||||||
"""Testing export role permissions."""
|
"""Testing export role permissions."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
@ -818,7 +818,7 @@ class RolePermissionTests(SupersetTestCase):
|
||||||
raise Exception(f"Some views are not secured:\n{view_str}")
|
raise Exception(f"Some views are not secured:\n{view_str}")
|
||||||
|
|
||||||
|
|
||||||
class SecurityManagerTests(SupersetTestCase):
|
class TestSecurityManager(SupersetTestCase):
|
||||||
"""
|
"""
|
||||||
Testing the Security Manager.
|
Testing the Security Manager.
|
||||||
"""
|
"""
|
||||||
|
|
@ -930,7 +930,7 @@ class SecurityManagerTests(SupersetTestCase):
|
||||||
security_manager.raise_for_access(viz=test_viz)
|
security_manager.raise_for_access(viz=test_viz)
|
||||||
|
|
||||||
|
|
||||||
class RowLevelSecurityTests(SupersetTestCase):
|
class TestRowLevelSecurity(SupersetTestCase):
|
||||||
"""
|
"""
|
||||||
Testing Row Level Security
|
Testing Row Level Security
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import unittest
|
||||||
from superset.sql_parse import ParsedQuery, Table
|
from superset.sql_parse import ParsedQuery, Table
|
||||||
|
|
||||||
|
|
||||||
class SupersetTestCase(unittest.TestCase):
|
class TestSupersetSqlParse(unittest.TestCase):
|
||||||
def extract_tables(self, query):
|
def extract_tables(self, query):
|
||||||
return ParsedQuery(query).tables
|
return ParsedQuery(query).tables
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ PRESTO_TEST_FEATURE_FLAGS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SqlValidatorEndpointTests(SupersetTestCase):
|
class TestSqlValidatorEndpoint(SupersetTestCase):
|
||||||
"""Testing for Sql Lab querytext validation endpoint"""
|
"""Testing for Sql Lab querytext validation endpoint"""
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
@ -114,7 +114,7 @@ class SqlValidatorEndpointTests(SupersetTestCase):
|
||||||
self.assertIn("Kaboom!", resp["error"])
|
self.assertIn("Kaboom!", resp["error"])
|
||||||
|
|
||||||
|
|
||||||
class BaseValidatorTests(SupersetTestCase):
|
class TestBaseValidator(SupersetTestCase):
|
||||||
"""Testing for the base sql validator"""
|
"""Testing for the base sql validator"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
@ -125,7 +125,7 @@ class BaseValidatorTests(SupersetTestCase):
|
||||||
self.validator.validate(None, None, None)
|
self.validator.validate(None, None, None)
|
||||||
|
|
||||||
|
|
||||||
class PrestoValidatorTests(SupersetTestCase):
|
class TestPrestoValidator(SupersetTestCase):
|
||||||
"""Testing for the prestodb sql validator"""
|
"""Testing for the prestodb sql validator"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ from superset.utils.core import DbColumnType, get_example_database, FilterOperat
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class DatabaseModelTestCase(SupersetTestCase):
|
class TestDatabaseModel(SupersetTestCase):
|
||||||
def test_is_time_druid_time_col(self):
|
def test_is_time_druid_time_col(self):
|
||||||
"""Druid has a special __time column"""
|
"""Druid has a special __time column"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,9 @@ QUERY_2 = "SELECT * FROM NO_TABLE"
|
||||||
QUERY_3 = "SELECT * FROM birth_names LIMIT 10"
|
QUERY_3 = "SELECT * FROM birth_names LIMIT 10"
|
||||||
|
|
||||||
|
|
||||||
class SqlLabTests(SupersetTestCase):
|
class TestSqlLab(SupersetTestCase):
|
||||||
"""Testings for Sql Lab"""
|
"""Testings for Sql Lab"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(SqlLabTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def run_some_queries(self):
|
def run_some_queries(self):
|
||||||
db.session.query(Query).delete()
|
db.session.query(Query).delete()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from unittest.mock import Mock, patch
|
||||||
from superset.stats_logger import StatsdStatsLogger
|
from superset.stats_logger import StatsdStatsLogger
|
||||||
|
|
||||||
|
|
||||||
class StatsdStatsLoggerTest(TestCase):
|
class TestStatsdStatsLogger(TestCase):
|
||||||
def verify_client_calls(self, logger, client):
|
def verify_client_calls(self, logger, client):
|
||||||
logger.incr("foo1")
|
logger.incr("foo1")
|
||||||
client.incr.assert_called_once()
|
client.incr.assert_called_once()
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,7 @@ mock_positions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CacheWarmUpTests(SupersetTestCase):
|
class TestCacheWarmUp(SupersetTestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(CacheWarmUpTests, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def test_get_form_data_chart_only(self):
|
def test_get_form_data_chart_only(self):
|
||||||
chart_id = 1
|
chart_id = 1
|
||||||
result = get_form_data(chart_id, None)
|
result = get_form_data(chart_id, None)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from superset import is_feature_enabled
|
||||||
from tests.base_tests import SupersetTestCase
|
from tests.base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class TaggingTests(SupersetTestCase):
|
class TestTagging(SupersetTestCase):
|
||||||
@skipUnless(
|
@skipUnless(
|
||||||
(is_feature_enabled("TAGGING_SYSTEM") == False),
|
(is_feature_enabled("TAGGING_SYSTEM") == False),
|
||||||
"skipping as tagging endpoints are not enabled",
|
"skipping as tagging endpoints are not enabled",
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ from tests.test_app import app
|
||||||
from .base_tests import SupersetTestCase
|
from .base_tests import SupersetTestCase
|
||||||
|
|
||||||
|
|
||||||
class ThumbnailsSeleniumLive(LiveServerTestCase):
|
class TestThumbnailsSeleniumLive(LiveServerTestCase):
|
||||||
def create_app(self):
|
def create_app(self):
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ class ThumbnailsSeleniumLive(LiveServerTestCase):
|
||||||
self.assertEqual(response.getcode(), 202)
|
self.assertEqual(response.getcode(), 202)
|
||||||
|
|
||||||
|
|
||||||
class ThumbnailsTests(SupersetTestCase):
|
class TestThumbnails(SupersetTestCase):
|
||||||
|
|
||||||
mock_image = b"bytes mock image"
|
mock_image = b"bytes mock image"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ def mock_to_adhoc(filt, expressionType="SIMPLE", clause="where"):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class UtilsTestCase(SupersetTestCase):
|
class TestUtils(SupersetTestCase):
|
||||||
def test_json_int_dttm_ser(self):
|
def test_json_int_dttm_ser(self):
|
||||||
dttm = datetime(2020, 1, 1)
|
dttm = datetime(2020, 1, 1)
|
||||||
ts = 1577836800000.0
|
ts = 1577836800000.0
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ from .utils import load_fixture
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BaseVizTestCase(SupersetTestCase):
|
class TestBaseViz(SupersetTestCase):
|
||||||
def test_constructor_exception_no_datasource(self):
|
def test_constructor_exception_no_datasource(self):
|
||||||
form_data = {}
|
form_data = {}
|
||||||
datasource = None
|
datasource = None
|
||||||
|
|
@ -166,7 +166,7 @@ class BaseVizTestCase(SupersetTestCase):
|
||||||
self.assertEqual(app.config["CACHE_DEFAULT_TIMEOUT"], test_viz.cache_timeout)
|
self.assertEqual(app.config["CACHE_DEFAULT_TIMEOUT"], test_viz.cache_timeout)
|
||||||
|
|
||||||
|
|
||||||
class TableVizTestCase(SupersetTestCase):
|
class TestTableViz(SupersetTestCase):
|
||||||
def test_get_data_applies_percentage(self):
|
def test_get_data_applies_percentage(self):
|
||||||
form_data = {
|
form_data = {
|
||||||
"groupby": ["groupA", "groupB"],
|
"groupby": ["groupA", "groupB"],
|
||||||
|
|
@ -443,7 +443,7 @@ class TableVizTestCase(SupersetTestCase):
|
||||||
self.assertEqual(["sum_value"], data["columns"])
|
self.assertEqual(["sum_value"], data["columns"])
|
||||||
|
|
||||||
|
|
||||||
class DistBarVizTestCase(SupersetTestCase):
|
class TestDistBarViz(SupersetTestCase):
|
||||||
def test_groupby_nulls(self):
|
def test_groupby_nulls(self):
|
||||||
form_data = {
|
form_data = {
|
||||||
"metrics": ["votes"],
|
"metrics": ["votes"],
|
||||||
|
|
@ -519,7 +519,7 @@ class DistBarVizTestCase(SupersetTestCase):
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
|
|
||||||
|
|
||||||
class PairedTTestTestCase(SupersetTestCase):
|
class TestPairedTTest(SupersetTestCase):
|
||||||
def test_get_data_transforms_dataframe(self):
|
def test_get_data_transforms_dataframe(self):
|
||||||
form_data = {
|
form_data = {
|
||||||
"groupby": ["groupA", "groupB", "groupC"],
|
"groupby": ["groupA", "groupB", "groupC"],
|
||||||
|
|
@ -659,7 +659,7 @@ class PairedTTestTestCase(SupersetTestCase):
|
||||||
self.assertEqual(data, expected)
|
self.assertEqual(data, expected)
|
||||||
|
|
||||||
|
|
||||||
class PartitionVizTestCase(SupersetTestCase):
|
class TestPartitionViz(SupersetTestCase):
|
||||||
@patch("superset.viz.BaseViz.query_obj")
|
@patch("superset.viz.BaseViz.query_obj")
|
||||||
def test_query_obj_time_series_option(self, super_query_obj):
|
def test_query_obj_time_series_option(self, super_query_obj):
|
||||||
datasource = self.get_datasource_mock()
|
datasource = self.get_datasource_mock()
|
||||||
|
|
@ -863,7 +863,7 @@ class PartitionVizTestCase(SupersetTestCase):
|
||||||
self.assertEqual(7, len(test_viz.nest_values.mock_calls))
|
self.assertEqual(7, len(test_viz.nest_values.mock_calls))
|
||||||
|
|
||||||
|
|
||||||
class RoseVisTestCase(SupersetTestCase):
|
class TestRoseVis(SupersetTestCase):
|
||||||
def test_rose_vis_get_data(self):
|
def test_rose_vis_get_data(self):
|
||||||
raw = {}
|
raw = {}
|
||||||
t1 = pd.Timestamp("2000")
|
t1 = pd.Timestamp("2000")
|
||||||
|
|
@ -899,7 +899,7 @@ class RoseVisTestCase(SupersetTestCase):
|
||||||
self.assertEqual(expected, res)
|
self.assertEqual(expected, res)
|
||||||
|
|
||||||
|
|
||||||
class TimeSeriesTableVizTestCase(SupersetTestCase):
|
class TestTimeSeriesTableViz(SupersetTestCase):
|
||||||
def test_get_data_metrics(self):
|
def test_get_data_metrics(self):
|
||||||
form_data = {"metrics": ["sum__A", "count"], "groupby": []}
|
form_data = {"metrics": ["sum__A", "count"], "groupby": []}
|
||||||
datasource = self.get_datasource_mock()
|
datasource = self.get_datasource_mock()
|
||||||
|
|
@ -956,7 +956,7 @@ class TimeSeriesTableVizTestCase(SupersetTestCase):
|
||||||
test_viz.query_obj()
|
test_viz.query_obj()
|
||||||
|
|
||||||
|
|
||||||
class BaseDeckGLVizTestCase(SupersetTestCase):
|
class TestBaseDeckGLViz(SupersetTestCase):
|
||||||
def test_get_metrics(self):
|
def test_get_metrics(self):
|
||||||
form_data = load_fixture("deck_path_form_data.json")
|
form_data = load_fixture("deck_path_form_data.json")
|
||||||
datasource = self.get_datasource_mock()
|
datasource = self.get_datasource_mock()
|
||||||
|
|
@ -1133,7 +1133,7 @@ class BaseDeckGLVizTestCase(SupersetTestCase):
|
||||||
assert expected_results.get(mock_key) == adhoc_filters
|
assert expected_results.get(mock_key) == adhoc_filters
|
||||||
|
|
||||||
|
|
||||||
class TimeSeriesVizTestCase(SupersetTestCase):
|
class TestTimeSeriesViz(SupersetTestCase):
|
||||||
def test_timeseries_unicode_data(self):
|
def test_timeseries_unicode_data(self):
|
||||||
datasource = self.get_datasource_mock()
|
datasource = self.get_datasource_mock()
|
||||||
form_data = {"groupby": ["name"], "metrics": ["sum__payout"]}
|
form_data = {"groupby": ["name"], "metrics": ["sum__payout"]}
|
||||||
|
|
@ -1258,7 +1258,7 @@ class TimeSeriesVizTestCase(SupersetTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class BigNumberVizTestCase(SupersetTestCase):
|
class TestBigNumberViz(SupersetTestCase):
|
||||||
def test_get_data(self):
|
def test_get_data(self):
|
||||||
datasource = self.get_datasource_mock()
|
datasource = self.get_datasource_mock()
|
||||||
df = pd.DataFrame(
|
df = pd.DataFrame(
|
||||||
|
|
|
||||||
6
tox.ini
6
tox.ini
|
|
@ -18,8 +18,10 @@
|
||||||
commands =
|
commands =
|
||||||
{toxinidir}/superset/bin/superset db upgrade
|
{toxinidir}/superset/bin/superset db upgrade
|
||||||
{toxinidir}/superset/bin/superset init
|
{toxinidir}/superset/bin/superset init
|
||||||
nosetests tests/load_examples_test.py
|
pytest -ra -q tests/load_examples_test.py
|
||||||
nosetests --exclude=load_examples_test {posargs:tests}
|
# use -s to be able to use break pointers.
|
||||||
|
# no args or tests/* can be passed as an argument to run all tests
|
||||||
|
pytest --ignore=load_examples_test {posargs}
|
||||||
deps =
|
deps =
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
-rrequirements-dev.txt
|
-rrequirements-dev.txt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue