MCPcopy Create free account
hub / github.com/alibaba/open-code-review / FormatCommentFallbackTest

Class FormatCommentFallbackTest

examples/gitlab_ci/post_review_test.py:139–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137
138
139class FormatCommentFallbackTest(unittest.TestCase):
140 def test_plain_content(self):
141 md = pr.format_comment_fallback({"content": "hello", "path": "a.py"})
142 self.assertIn("### 📄 `a.py`", md)
143 self.assertIn("hello", md)
144
145 def test_with_line_range(self):
146 md = pr.format_comment_fallback({
147 "content": "issue",
148 "path": "a.py",
149 "start_line": 3,
150 "end_line": 7,
151 })
152 self.assertIn("(L3-L7)", md)
153
154 def test_with_suggestion(self):
155 md = pr.format_comment_fallback(comment(
156 content="fix this",
157 existing_code="x = 1",
158 suggestion_code="x = 2",
159 ))
160 self.assertIn("<details><summary>💡 Suggested Change</summary>", md)
161 self.assertIn("**Before:**\n```\nx = 1\n```", md)
162 self.assertIn("**After:**\n```\nx = 2\n```", md)
163 self.assertIn("</details>", md)
164
165 def test_badge_prefix(self):
166 md = pr.format_comment_fallback(comment(
167 content="issue",
168 category="style",
169 severity="low",
170 ))
171 self.assertTrue(md.startswith("[style · low]\n"))
172
173 def test_reason_appended(self):
174 md = pr.format_comment_fallback(comment(content="issue"), reason="Routed to summary (severity low)")
175 self.assertIn("*Routed to summary (severity low)*", md)
176
177 def test_suggestion_without_existing(self):
178 md = pr.format_comment_fallback(comment(
179 content="fix this",
180 suggestion_code="x = 2",
181 ))
182 self.assertNotIn("<details>", md)
183
184
185# --------------------------------------------------------------------------- #

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected