Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tests can failed on different order executions #17885

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions tests/integration_tests/charts/data/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,25 @@ def assert_row_count(rv: Response, expected_row_count: int):
assert rv.json["result"][0]["rowcount"] == expected_row_count

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@mock.patch(
"superset.common.query_context_factory.config", {**app.config, "ROW_LIMIT": 7},
)
def test_without_row_limit__row_count_as_default_row_limit(self):
# arrange
row_limit_before = app.config["ROW_LIMIT"]
expected_row_count = 7
app.config["ROW_LIMIT"] = expected_row_count
del self.query_context_payload["queries"][0]["row_limit"]
# act
rv = self.post_assert_metric(CHART_DATA_URI, self.query_context_payload, "data")
# assert
self.assert_row_count(rv, expected_row_count)
# cleanup
app.config["ROW_LIMIT"] = row_limit_before

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@mock.patch(
"superset.common.query_context_factory.config",
{**app.config, "SAMPLES_ROW_LIMIT": 5},
)
def test_as_samples_without_row_limit__row_count_as_default_samples_row_limit(self):
# arrange
samples_row_limit_before = app.config["SAMPLES_ROW_LIMIT"]
expected_row_count = 5
app.config["SAMPLES_ROW_LIMIT"] = expected_row_count
self.query_context_payload["result_type"] = ChartDataResultType.SAMPLES
Expand All @@ -154,15 +156,13 @@ def test_as_samples_without_row_limit__row_count_as_default_samples_row_limit(se
# assert
self.assert_row_count(rv, expected_row_count)

# cleanup
app.config["SAMPLES_ROW_LIMIT"] = samples_row_limit_before

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@mock.patch(
"superset.utils.core.current_app.config", {**app.config, "SQL_MAX_ROW": 10},
)
def test_with_row_limit_bigger_then_sql_max_row__rowcount_as_sql_max_row(self):
# arrange
expected_row_count = 10
max_row_before = app.config["SQL_MAX_ROW"]
app.config["SQL_MAX_ROW"] = expected_row_count
self.query_context_payload["queries"][0]["row_limit"] = 10000000

# act
Expand All @@ -171,9 +171,6 @@ def test_with_row_limit_bigger_then_sql_max_row__rowcount_as_sql_max_row(self):
# assert
self.assert_row_count(rv, expected_row_count)

# cleanup
app.config["SQL_MAX_ROW"] = max_row_before

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@mock.patch(
"superset.utils.core.current_app.config", {**app.config, "SQL_MAX_ROW": 5},
Expand Down