diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py
index 483787aa..da9e95f2 100644
--- a/tests/unittest/test_convert_to_markdown.py
+++ b/tests/unittest/test_convert_to_markdown.py
@@ -1,4 +1,7 @@
# Generated by CodiumAI
+import textwrap
+from unittest.mock import Mock
+
from pr_agent.algo.utils import PRReviewHeader, convert_to_markdown_v2
from pr_agent.tools.pr_description import insert_br_after_x_chars
@@ -48,9 +51,143 @@ class TestConvertToMarkdown:
input_data = {'review': {
'estimated_effort_to_review_[1-5]': '1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n',
'relevant_tests': 'No\n', 'possible_issues': 'No\n', 'security_concerns': 'No\n'}}
+
+ expected_output = textwrap.dedent(f"""\
+ {PRReviewHeader.REGULAR.value} ๐
+
+ Here are some key observations to aid the review process:
+
+
+ โฑ๏ธ Estimated effort to review: 1 ๐ตโชโชโชโช |
+ ๐งช No relevant tests |
+ Possible issues: No
+ |
+ ๐ No security concerns identified |
+
+ """)
+
+ assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()
+
+ def test_simple_dictionary_input_without_gfm_supported(self):
+ input_data = {'review': {
+ 'estimated_effort_to_review_[1-5]': '1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n',
+ 'relevant_tests': 'No\n', 'possible_issues': 'No\n', 'security_concerns': 'No\n'}}
+
+ expected_output = textwrap.dedent("""\
+ ## PR Reviewer Guide ๐
+
+ Here are some key observations to aid the review process:
+
+ ### โฑ๏ธ Estimated effort to review: 1 ๐ตโชโชโชโช
+
+ ### ๐งช No relevant tests
+
+ ### Possible issues: No
- expected_output = f'{PRReviewHeader.REGULAR.value} ๐\n\nHere are some key observations to aid the review process:\n\n\nโฑ๏ธ Estimated effort to review: 1 ๐ตโชโชโชโช |
\n๐งช No relevant tests |
\n Possible issues: No\n |
\n๐ No security concerns identified |
\n
'
+ ### ๐ No security concerns identified
+ """)
+
+ assert convert_to_markdown_v2(input_data, gfm_supported=False).strip() == expected_output.strip()
+
+ def test_key_issues_to_review(self):
+ input_data = {'review': {
+ 'key_issues_to_review': [
+ {
+ 'relevant_file' : 'src/utils.py',
+ 'issue_header' : 'Code Smell',
+ 'issue_content' : 'The function is too long and complex.',
+ 'start_line': 30,
+ 'end_line': 50,
+ }
+ ]
+ }}
+ mock_git_provider = Mock()
+ reference_link = 'https://github.com/qodo/pr-agent/pull/1/files#diff-hashvalue-R174'
+ mock_git_provider.get_line_link.return_value = reference_link
+
+ expected_output = textwrap.dedent(f"""\
+ ## PR Reviewer Guide ๐
+
+ Here are some key observations to aid the review process:
+
+
+ โก Recommended focus areas for review
+
+ Code Smell The function is too long and complex.
+
+ |
+
+ """)
+
+ assert convert_to_markdown_v2(input_data, git_provider=mock_git_provider).strip() == expected_output.strip()
+ mock_git_provider.get_line_link.assert_called_with('src/utils.py', 30, 50)
+
+ def test_ticket_compliance(self):
+ input_data = {'review': {
+ 'ticket_compliance_check': [
+ {
+ 'ticket_url': 'https://example.com/ticket/123',
+ 'ticket_requirements': '- Requirement 1\n- Requirement 2\n',
+ 'fully_compliant_requirements': '- Requirement 1\n- Requirement 2\n',
+ 'not_compliant_requirements': '',
+ 'requires_further_human_verification': '',
+ }
+ ]
+ }}
+
+ expected_output = textwrap.dedent("""\
+ ## PR Reviewer Guide ๐
+
+ Here are some key observations to aid the review process:
+
+
+
+
+ **๐ซ Ticket compliance analysis โ
**
+
+
+
+ **[123](https://example.com/ticket/123) - Fully compliant**
+
+ Compliant requirements:
+
+ - Requirement 1
+ - Requirement 2
+
+
+
+ |
+
+ """)
+
+ assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()
+
+ def test_can_be_split(self):
+ input_data = {'review': {
+ 'can_be_split': [
+ {
+ 'relevant_files': [
+ 'src/file1.py',
+ 'src/file2.py'
+ ],
+ 'title': 'Split PR into smaller parts',
+ }
+ ]
+ }
+ }
+
+ expected_output = textwrap.dedent("""\
+ ## PR Reviewer Guide ๐
+
+ Here are some key observations to aid the review process:
+
+
+ ๐ No multiple PR themes
+
+ |
+
+ """)
assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()