diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b03e50..6c821cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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_git_utils.py -v --cov --cov-branch --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 diff --git a/tests/test_git_utils.py b/tests/test_git_utils.py new file mode 100644 index 0000000..0952b81 --- /dev/null +++ b/tests/test_git_utils.py @@ -0,0 +1,49 @@ +import pytest +from src.git_utils import ( + clean_response, + add_signature_to_comment, + get_github_client, + get_repository, + get_open_issues, + get_issue_comments, + create_issue_comment, + get_issue_details, + search_issues, + write_issue_response, + clone_repository, + update_repository, + get_pr_branch, + get_development_branch, + create_pull_request, + create_pull_request_from_issue, + push_changes_with_authentication, + is_pull_request, + update_self_repo, + perform_github_search, + has_linked_pr, + get_linked_pr +) +from github import Github +from unittest.mock import patch, MagicMock + + +@patch('src.git_utils.get_github_client') +def test_get_github_client(mock_get_github_client): + mock_get_github_client.return_value = MagicMock(spec=Github) + client = get_github_client() + assert isinstance(client, Github) + + +def test_clean_response(): + response = "This is a test response. " + cleaned_response = clean_response(response) + assert "" not in cleaned_response + + +def test_add_signature_to_comment(): + comment_text = "This is a comment." + model = "test-model" + signed_comment = add_signature_to_comment(comment_text, model) + assert "test-model" in signed_comment + +# Add more tests for other functions...