Skip to content

Commit 8a8ba77

Browse files
committed
add test
1 parent e58db60 commit 8a8ba77

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/sentry/grouping/test_parameterization.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sentry.grouping.parameterization import (
1414
ParameterizationRegex,
1515
Parameterizer,
16+
_log_example_data,
1617
experimental_parameterizer,
1718
is_valid_ip,
1819
parameterizer,
@@ -717,3 +718,33 @@ def test_replacement_callback_false_positive_triggers_individual_regex_fallback(
717718
)
718719
== 1
719720
)
721+
722+
723+
@patch("sentry.grouping.parameterization.logger")
724+
def test_example_data_logging(mock_logger: MagicMock) -> None:
725+
for i in range(15):
726+
_log_example_data("dog_fact_1", extra={"input_str": "dogs are great", "num": i}, limit=10)
727+
728+
for i in range(105):
729+
_log_example_data("dog_fact_2", extra={"input_str": "all dogs are good dogs", "num": i})
730+
731+
# In the first loop, we specified a limit of 10, so the logger was called 10 times, even though
732+
# we called the helper 15 times
733+
assert (
734+
count_matching_calls(
735+
mock_logger.info,
736+
"grouping.parameterization.dog_fact_1",
737+
extra={"input_str": "dogs are great", "num": ANY},
738+
)
739+
== 10
740+
)
741+
# In the second loop, we didn't specify a limit, so the logger was called 100 times (the
742+
# default limit), even though we called the helper 105 times
743+
assert (
744+
count_matching_calls(
745+
mock_logger.info,
746+
"grouping.parameterization.dog_fact_2",
747+
extra={"input_str": "all dogs are good dogs", "num": ANY},
748+
)
749+
== 100
750+
)

0 commit comments

Comments
 (0)