Skip to content

Commit

Permalink
Removing the mocking for query id generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nachiappan Veerappan Nachiappan authored and Nachiappan Veerappan Nachiappan committed Jun 7, 2024
1 parent 283bead commit 84be77c
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions tests/web/test_db_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,26 +749,23 @@ def test_clickhouse_settings_applied_to_query_id(
clickhouse_query_settings: Dict[str, Any] = {}
stats: dict[str, Any] = {}

with mock.patch(
"snuba.web.db_query.get_query_cache_key", return_value="test_query_id"
) as mock_get_query_cache_key:
query_id = mock_get_query_cache_key(formatted_query)
execute_query_with_readthrough_caching(
clickhouse_query=query,
query_settings=query_settings,
formatted_query=formatted_query,
reader=reader,
timer=Timer("foo"),
stats=stats,
clickhouse_query_settings=clickhouse_query_settings,
robust=False,
query_id=query_id,
referrer="test",
)
if test_cache_hit_simple:
assert stats["cache_hit_simple"] == 1
else:
assert "cache_hit_simple" not in stats
assert clickhouse_query_settings["query_id"].startswith(expected_startswith)
cached_value = _get_cache_partition(reader).get(query_id)
assert cached_value is not None, "cached_value is None"
execute_query_with_readthrough_caching(
clickhouse_query=query,
query_settings=query_settings,
formatted_query=formatted_query,
reader=reader,
timer=Timer("foo"),
stats=stats,
clickhouse_query_settings=clickhouse_query_settings,
robust=False,
query_id="test_query_id",
referrer="test",
)

if test_cache_hit_simple:
assert stats["cache_hit_simple"] == 1
else:
assert "cache_hit_simple" not in stats
assert clickhouse_query_settings["query_id"].startswith(expected_startswith)
cached_value = _get_cache_partition(reader).get("test_query_id")
assert cached_value is not None, "cached_value is None"

0 comments on commit 84be77c

Please sign in to comment.