Ruff after aider
This commit is contained in:
parent
0ae3b5777a
commit
d93074f184
|
@ -1,10 +1,7 @@
|
||||||
import subprocess
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
from aider_gitea import has_commits_on_branch
|
||||||
|
|
||||||
from aider_gitea import has_commits_on_branch, get_commit_messages
|
|
||||||
|
|
||||||
|
|
||||||
class TestHasCommitsOnBranch:
|
class TestHasCommitsOnBranch:
|
||||||
|
@ -17,32 +14,41 @@ class TestHasCommitsOnBranch:
|
||||||
def test_has_commits_true(self, mock_get_commit_messages):
|
def test_has_commits_true(self, mock_get_commit_messages):
|
||||||
# Setup mock to return some commit messages
|
# Setup mock to return some commit messages
|
||||||
mock_get_commit_messages.return_value = ['Commit 1', 'Commit 2']
|
mock_get_commit_messages.return_value = ['Commit 1', 'Commit 2']
|
||||||
|
|
||||||
# Test function returns True when there are commits
|
# Test function returns True when there are commits
|
||||||
assert has_commits_on_branch(self.cwd, self.base_branch, self.current_branch) is True
|
assert (
|
||||||
|
has_commits_on_branch(self.cwd, self.base_branch, self.current_branch)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
# Verify get_commit_messages was called with correct arguments
|
# Verify get_commit_messages was called with correct arguments
|
||||||
mock_get_commit_messages.assert_called_once_with(
|
mock_get_commit_messages.assert_called_once_with(
|
||||||
self.cwd, self.base_branch, self.current_branch
|
self.cwd, self.base_branch, self.current_branch,
|
||||||
)
|
)
|
||||||
|
|
||||||
@patch('aider_gitea.get_commit_messages')
|
@patch('aider_gitea.get_commit_messages')
|
||||||
def test_has_commits_false(self, mock_get_commit_messages):
|
def test_has_commits_false(self, mock_get_commit_messages):
|
||||||
# Setup mock to return empty list
|
# Setup mock to return empty list
|
||||||
mock_get_commit_messages.return_value = []
|
mock_get_commit_messages.return_value = []
|
||||||
|
|
||||||
# Test function returns False when there are no commits
|
# Test function returns False when there are no commits
|
||||||
assert has_commits_on_branch(self.cwd, self.base_branch, self.current_branch) is False
|
assert (
|
||||||
|
has_commits_on_branch(self.cwd, self.base_branch, self.current_branch)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
# Verify get_commit_messages was called with correct arguments
|
# Verify get_commit_messages was called with correct arguments
|
||||||
mock_get_commit_messages.assert_called_once_with(
|
mock_get_commit_messages.assert_called_once_with(
|
||||||
self.cwd, self.base_branch, self.current_branch
|
self.cwd, self.base_branch, self.current_branch,
|
||||||
)
|
)
|
||||||
|
|
||||||
@patch('aider_gitea.get_commit_messages')
|
@patch('aider_gitea.get_commit_messages')
|
||||||
def test_has_commits_exception(self, mock_get_commit_messages):
|
def test_has_commits_exception(self, mock_get_commit_messages):
|
||||||
# Setup mock to raise an exception
|
# Setup mock to raise an exception
|
||||||
mock_get_commit_messages.side_effect = Exception("Git command failed")
|
mock_get_commit_messages.side_effect = Exception('Git command failed')
|
||||||
|
|
||||||
# Test function returns False when an exception occurs
|
# Test function returns False when an exception occurs
|
||||||
assert has_commits_on_branch(self.cwd, self.base_branch, self.current_branch) is False
|
assert (
|
||||||
|
has_commits_on_branch(self.cwd, self.base_branch, self.current_branch)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user