Ruff
This commit is contained in:
parent
d2691e2eba
commit
e2b3bdb811
|
@ -130,7 +130,9 @@ class GiteaClient:
|
||||||
continue
|
continue
|
||||||
yield repo['name']
|
yield repo['name']
|
||||||
|
|
||||||
def get_pull_request_comments(self, owner: str, repo: str, pull_number: int) -> list[dict]:
|
def get_pull_request_comments(
|
||||||
|
self, owner: str, repo: str, pull_number: int,
|
||||||
|
) -> list[dict]:
|
||||||
"""Get comments for a specific pull request.
|
"""Get comments for a specific pull request.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
import pytest
|
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from aider_gitea.gitea_client import GiteaClient
|
from aider_gitea.gitea_client import GiteaClient
|
||||||
|
|
||||||
|
|
||||||
class TestGiteaClient:
|
class TestGiteaClient:
|
||||||
def setup_method(self):
|
def setup_method(self):
|
||||||
"""Set up test fixtures."""
|
"""Set up test fixtures."""
|
||||||
self.gitea_url = "https://gitea.example.com"
|
self.gitea_url = 'https://gitea.example.com'
|
||||||
self.token = "test_token"
|
self.token = 'test_token'
|
||||||
self.client = GiteaClient(self.gitea_url, self.token)
|
self.client = GiteaClient(self.gitea_url, self.token)
|
||||||
self.owner = "test_owner"
|
self.owner = 'test_owner'
|
||||||
self.repo = "test_repo"
|
self.repo = 'test_repo'
|
||||||
|
|
||||||
def test_get_pull_request_comments(self, monkeypatch):
|
def test_get_pull_request_comments(self, monkeypatch):
|
||||||
"""Test retrieving comments for a pull request."""
|
"""Test retrieving comments for a pull request."""
|
||||||
pull_number = 123
|
pull_number = 123
|
||||||
expected_comments = [
|
expected_comments = [
|
||||||
{
|
{
|
||||||
"id": 1,
|
'id': 1,
|
||||||
"body": "This is a test comment",
|
'body': 'This is a test comment',
|
||||||
"user": {"login": "test_user"},
|
'user': {'login': 'test_user'},
|
||||||
"created_at": "2023-01-01T00:00:00Z",
|
'created_at': '2023-01-01T00:00:00Z',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
'id': 2,
|
||||||
"body": "Another test comment",
|
'body': 'Another test comment',
|
||||||
"user": {"login": "another_user"},
|
'user': {'login': 'another_user'},
|
||||||
"created_at": "2023-01-02T00:00:00Z",
|
'created_at': '2023-01-02T00:00:00Z',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -37,14 +37,16 @@ class TestGiteaClient:
|
||||||
|
|
||||||
# Mock the session.get method
|
# Mock the session.get method
|
||||||
mock_get = MagicMock(return_value=mock_response)
|
mock_get = MagicMock(return_value=mock_response)
|
||||||
monkeypatch.setattr(self.client.session, "get", mock_get)
|
monkeypatch.setattr(self.client.session, 'get', mock_get)
|
||||||
|
|
||||||
# Call the method
|
# Call the method
|
||||||
comments = self.client.get_pull_request_comments(self.owner, self.repo, pull_number)
|
comments = self.client.get_pull_request_comments(
|
||||||
|
self.owner, self.repo, pull_number,
|
||||||
|
)
|
||||||
|
|
||||||
# Verify the result
|
# Verify the result
|
||||||
assert comments == expected_comments
|
assert comments == expected_comments
|
||||||
|
|
||||||
# Verify the correct URL was called
|
# Verify the correct URL was called
|
||||||
expected_url = f"{self.gitea_url}/api/v1/repos/{self.owner}/{self.repo}/pulls/{pull_number}/comments"
|
expected_url = f'{self.gitea_url}/api/v1/repos/{self.owner}/{self.repo}/pulls/{pull_number}/comments'
|
||||||
mock_get.assert_called_once_with(expected_url)
|
mock_get.assert_called_once_with(expected_url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user