From 4c23866baa25a95a91886732f85e103ab468c779 Mon Sep 17 00:00:00 2001
From: NxPKG <116948796+NxPKG@users.noreply.github.com>
Date: Wed, 19 Jun 2024 07:07:19 +0000
Subject: [PATCH 1/3] check
---
tests/unittest/test_convert_to_markdown.py | 88 ++--------------------
1 file changed, 5 insertions(+), 83 deletions(-)
diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py
index b7f3f23a..f66d6d8e 100644
--- a/tests/unittest/test_convert_to_markdown.py
+++ b/tests/unittest/test_convert_to_markdown.py
@@ -1,88 +1,13 @@
-# Generated by KhulnaSoft
-from pr_assistant.algo.utils import convert_to_markdown
from pr_assistant.tools.pr_description import insert_br_after_x_chars
-"""
-Code Analysis
-
-Objective:
-The objective of the 'convert_to_markdown' function is to convert a dictionary of data into a markdown-formatted text.
-The function takes in a dictionary as input and recursively iterates through its keys and values to generate the
-markdown text.
-
-Inputs:
-- A dictionary of data containing information about a pull request.
-
-Flow:
-- Initialize an empty string variable 'markdown_text'.
-- Create a dictionary 'emojis' containing emojis for each key in the input dictionary.
-- Iterate through the input dictionary:
- - If the value is empty, continue to the next iteration.
- - If the value is a dictionary, recursively call the 'convert_to_markdown' function with the value as input and
- append the returned markdown text to 'markdown_text'.
- - If the value is a list:
- - If the key is 'code suggestions', add an additional line break to 'markdown_text'.
- - Get the corresponding emoji for the key from the 'emojis' dictionary. If no emoji is found, use a dash.
- - Append the emoji and key to 'markdown_text'.
- - Iterate through the items in the list:
- - If the item is a dictionary and the key is 'code suggestions', call the 'parse_code_suggestion' function with
- the item as input and append the returned markdown text to 'markdown_text'.
- - If the item is not empty, append it to 'markdown_text'.
- - If the value is not 'n/a', get the corresponding emoji for the key from the 'emojis' dictionary. If no emoji is
- found, use a dash. Append the emoji, key, and value to 'markdown_text'.
-- Return 'markdown_text'.
-
-Outputs:
-- A markdown-formatted string containing the information from the input dictionary.
-
-Additional aspects:
-- The function uses recursion to handle nested dictionaries.
-- The 'parse_code_suggestion' function is called for items in the 'code suggestions' list.
-- The function uses emojis to add visual cues to the markdown text.
-"""
-
-
-class TestConvertToMarkdown:
- # Tests that the function works correctly with a simple dictionary input
- def test_simple_dictionary_input(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'}, 'code_feedback': [
- {'relevant_file': '``pr_assistant/git_providers/git_provider.py\n``', 'language': 'python\n',
- '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/khulnasoft/pr-assistant-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]}
-
- expected_output = '## PR Reviewer Guide ๐\n\n
\n\n
โฑ๏ธ Estimated effort to review [1-5] | \n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n |
\n ๐งช Relevant tests | \n\nNo\n\n\n |
\n โก Possible issues | \n\nNo\n\n\n |
\n ๐ Security concerns | \n\nNo\n\n |
\n
\n\n\n Code feedback:
\n\n
relevant file | pr_assistant/git_providers/git_provider.py\n |
suggestion | \n\n\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\n |
relevant line | return "" |
\n\n '
-
- assert convert_to_markdown(input_data).strip() == expected_output.strip()
-
- # Tests that the function works correctly with an empty dictionary input
- def test_empty_dictionary_input(self):
- input_data = {}
-
- expected_output = ''
-
-
- assert convert_to_markdown(input_data).strip() == expected_output.strip()
-
- def test_dictionary_with_empty_dictionaries(self):
- input_data = {'review': {}, 'code_feedback': [{}]}
-
- expected_output = ''
-
-
- assert convert_to_markdown(input_data).strip() == expected_output.strip()
-
class TestBR:
def test_br1(self):
file_change_description = '- Imported `FilePatchInfo` and `EDIT_TYPE` from `pr_assistant.algo.types` instead of `pr_assistant.git_providers.git_provider`.'
file_change_description_br = insert_br_after_x_chars(file_change_description)
expected_output = ('Imported FilePatchInfo
and EDIT_TYPE
from '
- 'pr_assistant.algo.types
instead
of '
+ 'pr_assistant.algo.types
instead of '
'pr_assistant.git_providers.git_provider
.')
assert file_change_description_br == expected_output
- # print("-----")
- # print(file_change_description_br)
def test_br2(self):
file_change_description = (
@@ -93,14 +18,11 @@ def test_br2(self):
'ColorPaletteResourcesCollection ColorPaletteResourcesCollection '
'
ColorPaletteResourcesCollection
')
assert file_change_description_br == expected_output
- # print("-----")
- # print(file_change_description_br)
def test_br3(self):
file_change_description = 'Created a new class `ColorPaletteResourcesCollection` which extends `AvaloniaDictionary` and implements aaa'
file_change_description_br = insert_br_after_x_chars(file_change_description)
- assert file_change_description_br == ('Created a new class ColorPaletteResourcesCollection
which '
- 'extends
AvaloniaDictionary'
- '
and implements
aaa')
- # print("-----")
- # print(file_change_description_br)
+ expected_output = ('Created a new class ColorPaletteResourcesCollection
which '
+ 'extends
AvaloniaDictionary'
+ '
and implements
aaa')
+ assert file_change_description_br == expected_output
\ No newline at end of file
From 6ace4509d61e99f8444e6dd99bace49227d424d8 Mon Sep 17 00:00:00 2001
From: NxPKG <116948796+NxPKG@users.noreply.github.com>
Date: Wed, 19 Jun 2024 13:15:19 +0600
Subject: [PATCH 2/3] Update test_convert_to_markdown.py
Signed-off-by: NxPKG <116948796+NxPKG@users.noreply.github.com>
---
tests/unittest/test_convert_to_markdown.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py
index f66d6d8e..83b85f65 100644
--- a/tests/unittest/test_convert_to_markdown.py
+++ b/tests/unittest/test_convert_to_markdown.py
@@ -4,9 +4,7 @@ class TestBR:
def test_br1(self):
file_change_description = '- Imported `FilePatchInfo` and `EDIT_TYPE` from `pr_assistant.algo.types` instead of `pr_assistant.git_providers.git_provider`.'
file_change_description_br = insert_br_after_x_chars(file_change_description)
- expected_output = ('Imported FilePatchInfo
and EDIT_TYPE
from '
- 'pr_assistant.algo.types
instead of '
- 'pr_assistant.git_providers.git_provider
.')
+ expected_output = generate_html_list_item('Imported', 'FilePatchInfo', 'EDIT_TYPE', 'pr_assistant.algo.types', 'pr_assistant.git_providers.git_provider')
assert file_change_description_br == expected_output
def test_br2(self):
@@ -25,4 +23,4 @@ def test_br3(self):
expected_output = ('Created a new class ColorPaletteResourcesCollection
which '
'extends
AvaloniaDictionary'
'
and implements
aaa')
- assert file_change_description_br == expected_output
\ No newline at end of file
+ assert file_change_description_br == expected_output
From 2d758568f2a7f748f8014060530942094d471d65 Mon Sep 17 00:00:00 2001
From: NxPKG <116948796+NxPKG@users.noreply.github.com>
Date: Wed, 19 Jun 2024 13:21:10 +0600
Subject: [PATCH 3/3] Update test_convert_to_markdown.py
Signed-off-by: NxPKG <116948796+NxPKG@users.noreply.github.com>
---
tests/unittest/test_convert_to_markdown.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py
index 83b85f65..1154429f 100644
--- a/tests/unittest/test_convert_to_markdown.py
+++ b/tests/unittest/test_convert_to_markdown.py
@@ -4,7 +4,9 @@ class TestBR:
def test_br1(self):
file_change_description = '- Imported `FilePatchInfo` and `EDIT_TYPE` from `pr_assistant.algo.types` instead of `pr_assistant.git_providers.git_provider`.'
file_change_description_br = insert_br_after_x_chars(file_change_description)
- expected_output = generate_html_list_item('Imported', 'FilePatchInfo', 'EDIT_TYPE', 'pr_assistant.algo.types', 'pr_assistant.git_providers.git_provider')
+ expected_output = ('Imported FilePatchInfo
and EDIT_TYPE
from '
+ 'pr_assistant.algo.types
instead of '
+ 'pr_assistant.git_providers.git_provider
.')
assert file_change_description_br == expected_output
def test_br2(self):