-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9144e7
commit 9384f2d
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
from unittest.mock import patch, Mock | ||
import json | ||
from cloudcode.actions.reviews import CodeReviewer | ||
from fuzzywuzzy import fuzz | ||
|
||
with open("tests/data/actions/valid_review.json") as f: | ||
data = json.load(f) | ||
|
||
|
||
@pytest.mark.parametrize("valid_review", data) | ||
def test_review_pull_request(valid_review): | ||
# Act | ||
code_reviewer = CodeReviewer() | ||
result = code_reviewer.review_pull_request( | ||
valid_review["input"]["diff"], | ||
valid_review["input"]["title"], | ||
valid_review["input"]["description"], | ||
) | ||
|
||
assert fuzz.ratio(result, valid_review["output"]) > 95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
{ | ||
"input": {"diff": "", "title": "Test Title", "description": "Test description"}, | ||
"llm_resp": "{\"review\": [{\"topic\": \"Code Quality\", \"comment\": \"The code is well-structured and easy to read.\", \"reasoning\": \"The code follows best practices and coding standards.\", \"confidence\": \"High\"}, {\"topic\": \"Performance\", \"comment\": \"The code could be optimized for better performance.\", \"reasoning\": \"There are some inefficient loops and data structures used.\", \"confidence\": \"Medium\"}, {\"topic\": \"Security\", \"comment\": \"NA\", \"reasoning\": \"NA\", \"confidence\": \"NA\"}]}", | ||
"output": "\n## Code Review Feedback\n\n### Code Quality\n\n\n<details>\n<summary>The code is well-structured and easy to read.</summary>\n\n### Reason\nThe code follows best practices and coding standards.\n\n### Confidence\nHigh\n</details>\n\n### Performance\n\n\n<details>\n<summary>The code could be optimized for better performance.</summary>\n\n### Reason\nThere are some inefficient loops and data structures used.\n\n### Confidence\nMedium\n</details>\n\n### Security\n\n\n<details>\n<summary>NA</summary>\n\n### Reason\nNA\n\n### Confidence\nNA\n</details>\n" | ||
} | ||
] |