mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
@ -98,8 +98,8 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
|
||||
else:
|
||||
markdown_text += f"{PRReviewHeader.INCREMENTAL.value} 🔍\n\n"
|
||||
markdown_text += f"⏮️ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
|
||||
# if not output_data or not output_data.get('review', {}):
|
||||
# return ""
|
||||
if not output_data or not output_data.get('review', {}):
|
||||
return ""
|
||||
|
||||
if gfm_supported:
|
||||
markdown_text += "<table>\n"
|
||||
@ -112,10 +112,16 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
|
||||
emoji = emojis.get(key_nice, "")
|
||||
if 'Estimated effort to review' in key_nice:
|
||||
key_nice = 'Estimated effort to review'
|
||||
value_int = int(value)
|
||||
if value.isnumeric():
|
||||
value_int = int(value)
|
||||
else:
|
||||
try:
|
||||
value_int = int(value.split(',')[0])
|
||||
except ValueError:
|
||||
continue
|
||||
blue_bars = '🔵' * value_int
|
||||
white_bars = '⚪' * (5 - value_int)
|
||||
value = f"{value.strip()} {blue_bars}{white_bars}"
|
||||
value = f"{value_int} {blue_bars}{white_bars}"
|
||||
if gfm_supported:
|
||||
markdown_text += f"<tr><td>"
|
||||
markdown_text += f"{emoji} <strong>{key_nice}</strong>: {value}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Generated by CodiumAI
|
||||
from pr_agent.algo.utils import PRReviewHeader, convert_to_markdown
|
||||
from pr_agent.algo.utils import PRReviewHeader, convert_to_markdown_v2
|
||||
from pr_agent.tools.pr_description import insert_br_after_x_chars
|
||||
|
||||
"""
|
||||
@ -52,9 +52,10 @@ class TestConvertToMarkdown:
|
||||
'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n",
|
||||
'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]}
|
||||
|
||||
expected_output = f'{PRReviewHeader.REGULAR.value} 🔍\n\n<table>\n<tr><td> ⏱️ <strong>Estimated effort to review [1-5]</strong></td><td>\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n</td></tr>\n<tr><td> 🧪 <strong>Relevant tests</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> ⚡ <strong>Possible issues</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> 🔒 <strong>Security concerns</strong></td><td>\nNo\n\n</td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion </td><td>\n\n<strong>\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'
|
||||
|
||||
assert convert_to_markdown(input_data).strip() == expected_output.strip()
|
||||
expected_output = f'{PRReviewHeader.REGULAR} 🔍\n\n<table>\n<tr><td>⏱️ <strong>Estimated effort to review</strong>: 1 🔵⚪⚪⚪⚪</td></tr>\n<tr><td>🧪 <strong>No relevant tests</strong></td></tr>\n<tr><td>⚡ <strong>Possible issues</strong>: No\n</td></tr>\n<tr><td>🔒 <strong>No security concerns identified</strong></td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion </td><td>\n\n<strong>\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'
|
||||
|
||||
assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()
|
||||
|
||||
# Tests that the function works correctly with an empty dictionary input
|
||||
def test_empty_dictionary_input(self):
|
||||
@ -63,7 +64,7 @@ class TestConvertToMarkdown:
|
||||
expected_output = ''
|
||||
|
||||
|
||||
assert convert_to_markdown(input_data).strip() == expected_output.strip()
|
||||
assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()
|
||||
|
||||
def test_dictionary_with_empty_dictionaries(self):
|
||||
input_data = {'review': {}, 'code_feedback': [{}]}
|
||||
@ -71,7 +72,7 @@ class TestConvertToMarkdown:
|
||||
expected_output = ''
|
||||
|
||||
|
||||
assert convert_to_markdown(input_data).strip() == expected_output.strip()
|
||||
assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()
|
||||
|
||||
class TestBR:
|
||||
def test_br1(self):
|
||||
|
Reference in New Issue
Block a user