|
13 | 13 | from sentry.grouping.enhancer import (
|
14 | 14 | ENHANCEMENT_BASES,
|
15 | 15 | Enhancements,
|
| 16 | + _split_rules, |
16 | 17 | is_valid_profiling_action,
|
17 | 18 | is_valid_profiling_matcher,
|
18 | 19 | keep_profiling_rules,
|
@@ -665,6 +666,44 @@ def test_loads_enhancements_from_base64_string(self):
|
665 | 666 | assert str(enhancements.rules[0]) == "<EnhancementRule function:playFetch +app>"
|
666 | 667 | assert strategy_config.enhancements.id is None
|
667 | 668 |
|
| 669 | + @patch("sentry.grouping.enhancer._split_rules", wraps=_split_rules) |
| 670 | + def test_loads_split_enhancements_from_base64_string(self, split_rules_spy: MagicMock): |
| 671 | + # Using version 3 forces the enhancements to be split, and we know a split will happen |
| 672 | + # because the rule below has both an in-app and a contributes action |
| 673 | + enhancements = Enhancements.from_rules_text("function:playFetch +app +group", version=3) |
| 674 | + assert len(enhancements.rules) == 1 |
| 675 | + assert len(enhancements.classifier_rules) == 1 |
| 676 | + assert len(enhancements.contributes_rules) == 1 |
| 677 | + assert str(enhancements.rules[0]) == "<EnhancementRule function:playFetch +app +group>" |
| 678 | + assert str(enhancements.classifier_rules[0]) == "<EnhancementRule function:playFetch +app>" |
| 679 | + assert ( |
| 680 | + str(enhancements.contributes_rules[0]) == "<EnhancementRule function:playFetch +group>" |
| 681 | + ) |
| 682 | + assert enhancements.id is None |
| 683 | + assert split_rules_spy.call_count == 1 |
| 684 | + |
| 685 | + strategy_config = load_grouping_config( |
| 686 | + {"id": DEFAULT_GROUPING_CONFIG, "enhancements": enhancements.base64_string} |
| 687 | + ) |
| 688 | + assert len(strategy_config.enhancements.rules) == 1 |
| 689 | + assert len(strategy_config.enhancements.classifier_rules) == 1 |
| 690 | + assert len(strategy_config.enhancements.contributes_rules) == 1 |
| 691 | + assert ( |
| 692 | + str(strategy_config.enhancements.rules[0]) |
| 693 | + == "<EnhancementRule function:playFetch +app +group>" |
| 694 | + ) |
| 695 | + assert ( |
| 696 | + str(strategy_config.enhancements.classifier_rules[0]) |
| 697 | + == "<EnhancementRule function:playFetch +app>" |
| 698 | + ) |
| 699 | + assert ( |
| 700 | + str(strategy_config.enhancements.contributes_rules[0]) |
| 701 | + == "<EnhancementRule function:playFetch +group>" |
| 702 | + ) |
| 703 | + assert strategy_config.enhancements.id is None |
| 704 | + # Currently we re-split the rules when translating from base64 back to object |
| 705 | + assert split_rules_spy.call_count == 2 |
| 706 | + |
668 | 707 | def test_uses_default_enhancements_when_loading_string_with_invalid_version(self):
|
669 | 708 | enhancements = Enhancements.from_rules_text("function:playFetch +app")
|
670 | 709 | assert len(enhancements.rules) == 1
|
|
0 commit comments