Skip to content

Commit

Permalink
chore: Skips integration tests affected by legacy charts removal (apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Jan 10, 2025
1 parent 740fbf7 commit bbdc195
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 171 deletions.
2 changes: 2 additions & 0 deletions tests/integration_tests/async_events/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Any, Optional, Type
from unittest import mock

import pytest
import redis

from superset.async_events.cache_backend import (
Expand All @@ -30,6 +31,7 @@
from tests.integration_tests.test_app import app


@pytest.skip(reason="Needs to investigate this test", allow_module_level=True)
class TestAsyncEventApi(SupersetTestCase):
UUID = "943c920-32a5-412a-977d-b8e47d36f5a4"

Expand Down
4 changes: 4 additions & 0 deletions tests/integration_tests/cache_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
load_birth_names_data, # noqa: F401
)

pytest.skip(
reason="These tests will be changed to use the api/v1/data", allow_module_level=True
)


class TestCache(SupersetTestCase):
def setUp(self):
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/charts/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ def test_update_chart_validate_owners(self):
assert response == expected_response

@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_get_chart(self):
"""
Chart API: Test get chart
Expand Down Expand Up @@ -1170,6 +1171,7 @@ def test_get_charts_dashboard_filter(self):
assert result[0]["slice_name"] == self.chart.slice_name

@pytest.mark.usefixtures("create_charts_some_with_tags")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_get_charts_tag_filters(self):
"""
Chart API: Test get charts with tag filters
Expand Down Expand Up @@ -1970,7 +1972,6 @@ def test_gets_owned_created_favorited_by_me_filter(self):

@parameterized.expand(
[
"Top 10 Girl Name Share", # Legacy chart
"Pivot Table v2", # Non-legacy chart
],
)
Expand Down Expand Up @@ -2096,6 +2097,7 @@ def test_warm_up_cache_no_query_context(self) -> None:
}

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_warm_up_cache_no_datasource(self) -> None:
self.login(ADMIN_USERNAME)
slc = self.get_slice("Top 10 Girl Name Share")
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/charts/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def test_update_v1_response(self, mock_sm_g, mock_c_g, mock_u_g):
@patch("superset.utils.core.g")
@patch("superset.security.manager.g")
@pytest.mark.usefixtures("load_energy_table_with_slice")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_query_context_update_command(self, mock_sm_g, mock_g):
"""
Test that a user can generate the chart query context
Expand Down Expand Up @@ -421,6 +422,7 @@ def test_warm_up_cache_command_chart_not_found(self):
ChartWarmUpCacheCommand(99999, None, None).run()

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_warm_up_cache(self):
slc = self.get_slice("Top 10 Girl Name Share")
result = ChartWarmUpCacheCommand(slc.id, None, None).run()
Expand Down
10 changes: 10 additions & 0 deletions tests/integration_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_slice_endpoint(self):
assert resp.status_code == 404

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_viz_cache_key(self):
self.login(ADMIN_USERNAME)
slc = self.get_slice("Top 10 Girl Name Share")
Expand Down Expand Up @@ -173,6 +174,7 @@ def assert_admin_view_menus_in(role_name, assert_func):
assert_admin_view_menus_in("Gamma", self.assertNotIn)

@pytest.mark.usefixtures("load_energy_table_with_slice")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_save_slice(self):
self.login(ADMIN_USERNAME)
slice_name = f"Energy Sankey" # noqa: F541
Expand Down Expand Up @@ -349,6 +351,7 @@ def test_databaseview_edit(self):
"load_birth_names_dashboard_with_slices",
"load_energy_table_with_slice",
)
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_warm_up_cache(self):
self.login(ADMIN_USERNAME)
slc = self.get_slice("Top 10 Girl Name Share")
Expand Down Expand Up @@ -397,6 +400,7 @@ def test_warm_up_cache_error(self) -> None:
]

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_cache_logging(self):
self.login(ADMIN_USERNAME)
store_cache_keys = app.config["STORE_CACHE_KEYS_IN_METADATA_DB"]
Expand Down Expand Up @@ -559,6 +563,7 @@ def test_slice_payload_no_datasource(self):
)

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_explore_json(self):
tbl_id = self.table_ids.get("birth_names")
form_data = {
Expand All @@ -582,6 +587,7 @@ def test_explore_json(self):
assert data["rowcount"] == 2

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_explore_json_dist_bar_order(self):
tbl_id = self.table_ids.get("birth_names")
form_data = {
Expand Down Expand Up @@ -682,6 +688,7 @@ def test_explore_json_dist_bar_order(self):
"superset.extensions.feature_flag_manager._feature_flags",
GLOBAL_ASYNC_QUERIES=True,
)
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_explore_json_async(self):
tbl_id = self.table_ids.get("birth_names")
form_data = {
Expand Down Expand Up @@ -717,6 +724,7 @@ def test_explore_json_async(self):
]

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
@mock.patch.dict(
"superset.extensions.feature_flag_manager._feature_flags",
GLOBAL_ASYNC_QUERIES=True,
Expand Down Expand Up @@ -748,6 +756,7 @@ def test_explore_json_async_results_format(self):
new_callable=mock.PropertyMock,
)
@mock.patch("superset.viz.BaseViz.force_cached", new_callable=mock.PropertyMock)
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_explore_json_data(self, mock_force_cached, mock_cache):
tbl_id = self.table_ids.get("birth_names")
form_data = dict( # noqa: C418
Expand Down Expand Up @@ -786,6 +795,7 @@ def set(self):
"superset.utils.cache_manager.CacheManager.cache",
new_callable=mock.PropertyMock,
)
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_explore_json_data_no_login(self, mock_cache):
tbl_id = self.table_ids.get("birth_names")
form_data = dict( # noqa: C418
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/tasks/async_queries_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def test_soft_timeout_load_chart_data_into_cache(
]
)
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
@mock.patch.object(async_query_manager, "update_job")
def test_load_explore_json_into_cache(
self, cache_type, cache_backend, mock_update_job
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ def test_get_form_data_corrupted_json(self) -> None:
assert slc is None

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@pytest.mark.skip(reason="This test will be changed to use the api/v1/data")
def test_log_this(self) -> None:
# TODO: Add additional scenarios.
self.login(ADMIN_USERNAME)
Expand Down
170 changes: 0 additions & 170 deletions tests/integration_tests/viz_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# isort:skip_file
from datetime import datetime
import logging
from math import nan
from unittest.mock import Mock, patch

import numpy as np
Expand All @@ -27,7 +26,6 @@
import tests.integration_tests.test_app # noqa: F401
import superset.viz as viz
from superset import app
from superset.constants import NULL_STRING
from superset.exceptions import QueryObjectValidationError, SpatialException
from superset.utils.core import DTTM_ALIAS

Expand Down Expand Up @@ -177,174 +175,6 @@ def test_cache_timeout(self):
app.config["DATA_CACHE_CONFIG"]["CACHE_DEFAULT_TIMEOUT"] = data_cache_timeout


class TestDistBarViz(SupersetTestCase):
def test_groupby_nulls(self):
form_data = {
"metrics": ["votes"],
"adhoc_filters": [],
"groupby": ["toppings"],
"columns": [],
"order_desc": True,
}
datasource = self.get_datasource_mock()
df = pd.DataFrame(
{
"toppings": ["cheese", "pepperoni", "anchovies", None],
"votes": [3, 5, 1, 2],
}
)
test_viz = viz.DistributionBarViz(datasource, form_data)
data = test_viz.get_data(df)[0]
assert "votes" == data["key"]
expected_values = [
{"x": "pepperoni", "y": 5},
{"x": "cheese", "y": 3},
{"x": NULL_STRING, "y": 2},
{"x": "anchovies", "y": 1},
]
assert expected_values == data["values"]

def test_groupby_nans(self):
form_data = {
"metrics": ["count"],
"adhoc_filters": [],
"groupby": ["beds"],
"columns": [],
"order_desc": True,
}
datasource = self.get_datasource_mock()
df = pd.DataFrame({"beds": [0, 1, nan, 2], "count": [30, 42, 3, 29]})
test_viz = viz.DistributionBarViz(datasource, form_data)
data = test_viz.get_data(df)[0]
assert "count" == data["key"]
expected_values = [
{"x": "1.0", "y": 42},
{"x": "0.0", "y": 30},
{"x": "2.0", "y": 29},
{"x": NULL_STRING, "y": 3},
]

assert expected_values == data["values"]

def test_column_nulls(self):
form_data = {
"metrics": ["votes"],
"adhoc_filters": [],
"groupby": ["toppings"],
"columns": ["role"],
"order_desc": True,
}
datasource = self.get_datasource_mock()
df = pd.DataFrame(
{
"toppings": ["cheese", "pepperoni", "cheese", "pepperoni"],
"role": ["engineer", "engineer", None, None],
"votes": [3, 5, 1, 2],
}
)
test_viz = viz.DistributionBarViz(datasource, form_data)
data = test_viz.get_data(df)
expected = [
{
"key": NULL_STRING,
"values": [{"x": "pepperoni", "y": 2}, {"x": "cheese", "y": 1}],
},
{
"key": "engineer",
"values": [{"x": "pepperoni", "y": 5}, {"x": "cheese", "y": 3}],
},
]
assert expected == data

def test_column_metrics_in_order(self):
form_data = {
"metrics": ["z_column", "votes", "a_column"],
"adhoc_filters": [],
"groupby": ["toppings"],
"columns": [],
"order_desc": True,
}
datasource = self.get_datasource_mock()
df = pd.DataFrame(
{
"toppings": ["cheese", "pepperoni", "cheese", "pepperoni"],
"role": ["engineer", "engineer", None, None],
"votes": [3, 5, 1, 2],
"a_column": [3, 5, 1, 2],
"z_column": [3, 5, 1, 2],
}
)
test_viz = viz.DistributionBarViz(datasource, form_data)
data = test_viz.get_data(df)

expected = [
{
"key": "z_column",
"values": [{"x": "pepperoni", "y": 3.5}, {"x": "cheese", "y": 2.0}],
},
{
"key": "votes",
"values": [{"x": "pepperoni", "y": 3.5}, {"x": "cheese", "y": 2.0}],
},
{
"key": "a_column",
"values": [{"x": "pepperoni", "y": 3.5}, {"x": "cheese", "y": 2.0}],
},
]

assert expected == data

def test_column_metrics_in_order_with_breakdowns(self):
form_data = {
"metrics": ["z_column", "votes", "a_column"],
"adhoc_filters": [],
"groupby": ["toppings"],
"columns": ["role"],
"order_desc": True,
}
datasource = self.get_datasource_mock()
df = pd.DataFrame(
{
"toppings": ["cheese", "pepperoni", "cheese", "pepperoni"],
"role": ["engineer", "engineer", None, None],
"votes": [3, 5, 1, 2],
"a_column": [3, 5, 1, 2],
"z_column": [3, 5, 1, 2],
}
)
test_viz = viz.DistributionBarViz(datasource, form_data)
data = test_viz.get_data(df)

expected = [
{
"key": f"z_column, {NULL_STRING}",
"values": [{"x": "pepperoni", "y": 2}, {"x": "cheese", "y": 1}],
},
{
"key": "z_column, engineer",
"values": [{"x": "pepperoni", "y": 5}, {"x": "cheese", "y": 3}],
},
{
"key": f"votes, {NULL_STRING}",
"values": [{"x": "pepperoni", "y": 2}, {"x": "cheese", "y": 1}],
},
{
"key": "votes, engineer",
"values": [{"x": "pepperoni", "y": 5}, {"x": "cheese", "y": 3}],
},
{
"key": f"a_column, {NULL_STRING}",
"values": [{"x": "pepperoni", "y": 2}, {"x": "cheese", "y": 1}],
},
{
"key": "a_column, engineer",
"values": [{"x": "pepperoni", "y": 5}, {"x": "cheese", "y": 3}],
},
]

assert expected == data


class TestPairedTTest(SupersetTestCase):
def test_get_data_transforms_dataframe(self):
form_data = {
Expand Down

0 comments on commit bbdc195

Please sign in to comment.