Vitor-Avila commented on code in PR #30735:
URL: https://github.com/apache/superset/pull/30735#discussion_r1819815838
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -913,54 +913,102 @@ def test_extra_cache_keys_in_sql_expression(
@pytest.mark.usefixtures("app_context")
@pytest.mark.parametrize(
- "sql_expression,expected_cache_keys,has_extra_cache_keys",
+ "sql_expression,expected_cache_keys,has_extra_cache_keys,item_type",
[
- ("'{{ current_username() }}'", ["abc"], True),
- ("(user != 'abc')", [], False),
+ ("'{{ current_username() }}'", ["abc"], True, "columns"),
+ ("(user != 'abc')", [], False, "columns"),
+ ("{{ current_user_id() }}", [1], True, "metrics"),
+ ("COUNT(*)", [], False, "metrics"),
],
)
@patch("superset.jinja_context.get_user_id", return_value=1)
@patch("superset.jinja_context.get_username", return_value="abc")
-@patch("superset.jinja_context.get_user_email", return_value="[email protected]")
-def test_extra_cache_keys_in_columns(
- mock_user_email,
+def test_extra_cache_keys_in_adhoc_metrics_and_columns(
mock_username,
mock_user_id,
sql_expression,
expected_cache_keys,
has_extra_cache_keys,
+ item_type,
):
table = SqlaTable(
table_name="test_has_no_extra_cache_keys_table",
sql="SELECT 'abc' as user",
database=get_example_database(),
)
+ base_type = "metrics" if item_type == "columns" else "columns"
Review Comment:
Ok found a way to make this simpler. Going to commit a change here.
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -913,54 +913,102 @@ def test_extra_cache_keys_in_sql_expression(
@pytest.mark.usefixtures("app_context")
@pytest.mark.parametrize(
- "sql_expression,expected_cache_keys,has_extra_cache_keys",
+ "sql_expression,expected_cache_keys,has_extra_cache_keys,item_type",
[
- ("'{{ current_username() }}'", ["abc"], True),
- ("(user != 'abc')", [], False),
+ ("'{{ current_username() }}'", ["abc"], True, "columns"),
+ ("(user != 'abc')", [], False, "columns"),
+ ("{{ current_user_id() }}", [1], True, "metrics"),
+ ("COUNT(*)", [], False, "metrics"),
],
)
@patch("superset.jinja_context.get_user_id", return_value=1)
@patch("superset.jinja_context.get_username", return_value="abc")
-@patch("superset.jinja_context.get_user_email", return_value="[email protected]")
-def test_extra_cache_keys_in_columns(
- mock_user_email,
+def test_extra_cache_keys_in_adhoc_metrics_and_columns(
mock_username,
mock_user_id,
sql_expression,
expected_cache_keys,
has_extra_cache_keys,
+ item_type,
Review Comment:
of course!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]