|
6 | 6 | ANNOTATION_LIMIT, |
7 | 7 | AnnotationResult, |
8 | 8 | _build_command, |
9 | | - _sanitize_message, |
| 9 | + _sanitize_data, |
| 10 | + _sanitize_property, |
10 | 11 | generate_annotations, |
11 | 12 | ) |
12 | 13 | from validation.postfilter.engine import PostFilterResult |
@@ -56,29 +57,39 @@ def _make_result(findings: list[dict]) -> PostFilterResult: |
56 | 57 |
|
57 | 58 |
|
58 | 59 | # --------------------------------------------------------------------------- |
59 | | -# _sanitize_message |
| 60 | +# _sanitize_data |
60 | 61 | # --------------------------------------------------------------------------- |
61 | 62 |
|
62 | 63 |
|
63 | | -class TestSanitizeMessage: |
| 64 | +class TestSanitizeData: |
64 | 65 | def test_newlines_replaced(self): |
65 | | - assert " " in _sanitize_message("line1\nline2") |
66 | | - assert "\n" not in _sanitize_message("line1\nline2") |
| 66 | + assert " " in _sanitize_data("line1\nline2") |
| 67 | + assert "\n" not in _sanitize_data("line1\nline2") |
67 | 68 |
|
68 | 69 | def test_carriage_return_replaced(self): |
69 | | - assert "\r" not in _sanitize_message("a\rb") |
| 70 | + assert "\r" not in _sanitize_data("a\rb") |
70 | 71 |
|
71 | 72 | def test_crlf_replaced(self): |
72 | | - assert "\r\n" not in _sanitize_message("a\r\nb") |
| 73 | + assert "\r\n" not in _sanitize_data("a\r\nb") |
73 | 74 |
|
| 75 | + def test_colons_unchanged(self): |
| 76 | + assert _sanitize_data("key::value") == "key::value" |
| 77 | + |
| 78 | + def test_plain_text_unchanged(self): |
| 79 | + assert _sanitize_data("hello world") == "hello world" |
| 80 | + |
| 81 | + |
| 82 | +# --------------------------------------------------------------------------- |
| 83 | +# _sanitize_property |
| 84 | +# --------------------------------------------------------------------------- |
| 85 | + |
| 86 | + |
| 87 | +class TestSanitizeProperty: |
74 | 88 | def test_colons_encoded(self): |
75 | | - result = _sanitize_message("key::value") |
| 89 | + result = _sanitize_property("key::value") |
76 | 90 | assert "::" not in result |
77 | 91 | assert "%3A" in result |
78 | 92 |
|
79 | | - def test_plain_text_unchanged(self): |
80 | | - assert _sanitize_message("hello world") == "hello world" |
81 | | - |
82 | 93 |
|
83 | 94 | # --------------------------------------------------------------------------- |
84 | 95 | # _build_command |
@@ -163,7 +174,7 @@ def test_rule_id_fallback_in_message_body(self): |
163 | 174 | def test_suggestion_appended(self): |
164 | 175 | f = _make_finding(message="Bad path", suggestion="Use kebab-case") |
165 | 176 | cmd = _build_command(f) |
166 | | - assert "Bad path | Suggestion%3A Use kebab-case" in cmd |
| 177 | + assert "Bad path | Suggestion: Use kebab-case" in cmd |
167 | 178 |
|
168 | 179 | def test_no_suggestion(self): |
169 | 180 | f = _make_finding(message="Bad path") |
|
0 commit comments