Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Run tests with coverage
run: |
pytest tests/test_triggers.py -v --cov --cov-branch --cov-report=xml
pytest tests/test_triggers.py tests/test_agents.py -v --cov --cov-branch --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
46 changes: 46 additions & 0 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pytest
from src.agents import register_functions, create_user_agent, create_agent, parse_comments, generate_prompt
from autogen import ConversableAgent, AssistantAgent, UserProxyAgent
from github.Issue import Issue
from unittest.mock import MagicMock


def test_register_functions():
agent = MagicMock(spec=ConversableAgent)
registered_agent = register_functions(agent)
assert isinstance(registered_agent, ConversableAgent)


def test_create_user_agent():
user_agent = create_user_agent()
assert isinstance(user_agent, UserProxyAgent)


def test_create_agent():
agent_name = "edit_assistant"
llm_config = {"key": "value"}
agent = create_agent(agent_name, llm_config)
assert isinstance(agent, AssistantAgent)


def test_parse_comments():
repo_name = "test_repo"
repo_path = "/path/to/repo"
details = {}
issue = MagicMock(spec=Issue)
last_comment_str, comments_str, all_comments = parse_comments(
repo_name, repo_path, details, issue)
assert isinstance(last_comment_str, str)
assert isinstance(comments_str, str)
assert isinstance(all_comments, list)


def test_generate_prompt():
agent_name = "edit_assistant"
repo_name = "test_repo"
repo_path = "/path/to/repo"
details = {"title": "Test Title", "body": "Test Body"}
issue = MagicMock(spec=Issue)
prompt = generate_prompt(
agent_name, repo_name, repo_path, details, issue)
assert isinstance(prompt, str)