This commit is contained in:
27
tests/test_gitea.py
Normal file
27
tests/test_gitea.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
from test_config import settings
|
||||
|
||||
from lai_automation.gitea import GiteaClient
|
||||
|
||||
|
||||
def test_create_pull_request_requires_url() -> None:
|
||||
client = GiteaClient(settings(gitea_token="token"))
|
||||
response = Mock()
|
||||
response.json.return_value = {"number": 12}
|
||||
client.session.post = Mock(return_value=response)
|
||||
|
||||
with pytest.raises(ValueError, match="pull request URL"):
|
||||
client.create_pull_request("ai/failure-1", "Fix", "Body")
|
||||
|
||||
|
||||
def test_create_pull_request_returns_html_url() -> None:
|
||||
client = GiteaClient(settings(gitea_token="token"))
|
||||
response = Mock()
|
||||
response.json.return_value = {"html_url": "https://example.test/owner/lai/pulls/12"}
|
||||
client.session.post = Mock(return_value=response)
|
||||
|
||||
result = client.create_pull_request("ai/failure-1", "Fix", "Body")
|
||||
|
||||
assert result.endswith("/pulls/12")
|
||||
Reference in New Issue
Block a user