Skip to content

Commit

Permalink
fix: tests can failed on different order executions (apache#17885)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekisr authored and shcoderAlex committed Feb 7, 2022
1 parent 182289a commit eba130e
Showing 1 changed file with 10 additions and 13 deletions.
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

0 comments on commit eba130e

Please sign in to comment.