Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tests for PR#388 #389

Draft
wants to merge 1 commit into
base: adjust-message-copy
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
This step creates a new file test_github_comments.py in the `tests/…
…unit/torngit/` directory. The file contains a test class `TestGithubComments` with a single test method `test_build_comment_request_body_with_generate_tests_action`.

The test method does the following:
1. Sets up the necessary input parameters for the `build_comment_request_body` function.
2. Calls the `build_comment_request_body` function with these parameters.
3. Asserts that the returned result contains the correct "Generate Tests" action with the expected properties.
4. Verifies that the comment body is constructed correctly with the header, content, and footer.

This test ensures that the changes made to the `build_comment_request_body` function in `github.py` are working as expected, specifically the addition of the "Generate Tests" action.
  • Loading branch information
sentry-autofix[bot] authored Oct 16, 2024
commit df666249b292b60a5c93ee2b4a4028781e4f6d7c
33 changes: 33 additions & 0 deletions tests/unit/torngit/test_github_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest
from unittest.mock import AsyncMock, MagicMock
from shared.torngit.github import build_comment_request_body

class TestGithubComments:
@pytest.mark.asyncio
async def test_build_comment_request_body_with_generate_tests_action(self):
# Arrange
comment = "Test comment"
bot_name = "codecov-bot"
is_bot_comment = True
is_pull = True
is_analysis_requested = True
has_commit_data = True
include_button = True
comment_header = "Comment header"
comment_footer = "Comment footer"
repo = MagicMock()

# Act
result = await build_comment_request_body(
comment, bot_name, is_bot_comment, is_pull, is_analysis_requested,
has_commit_data, include_button, comment_header, comment_footer, repo
)

# Assert
assert "actions" in result
assert len(result["actions"]) == 1
action = result["actions"][0]
assert action["name"] == "Generate Tests"
assert action["type"] == "copilot-chat"
assert action["prompt"] == f"@{bot_name} generate tests for PR"
assert result["body"] == f"{comment_header}\n{comment}\n{comment_footer}"
Loading
Oops, something went wrong.