generated from coulomb/repo-seed
Fix Gitea issue label payloads
Some checks failed
Publish Python package / publish (push) Has been cancelled
Some checks failed
Publish Python package / publish (push) Has been cancelled
This commit is contained in:
@@ -6,8 +6,10 @@ These tests ensure the Gitea backend works correctly with the API.
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
from issue_core.backends.gitea.backend import GiteaBackend, GiteaAPIError
|
||||
from issue_core.core.models import Issue, IssueState, Label
|
||||
|
||||
|
||||
class TestGiteaBackend:
|
||||
@@ -96,6 +98,29 @@ class TestGiteaBackend:
|
||||
called_url = mock_request.call_args[1]['url'] if 'url' in mock_request.call_args[1] else mock_request.call_args[0][1]
|
||||
assert called_url == 'https://git.example.com/api/v1/repos/owner/repo'
|
||||
|
||||
def test_gitea_payload_omits_name_only_labels(self):
|
||||
"""Gitea issue payloads only include numeric label IDs."""
|
||||
now = datetime.now(timezone.utc)
|
||||
issue = Issue(
|
||||
id="",
|
||||
number=0,
|
||||
title="Test issue",
|
||||
description="Test description",
|
||||
state=IssueState.OPEN,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
labels=[
|
||||
Label(name="priority:low"),
|
||||
Label(name="source:rule", backend_id="not-a-number"),
|
||||
Label(name="existing", backend_id="42"),
|
||||
],
|
||||
)
|
||||
|
||||
payload = self.backend._unified_issue_to_gitea(issue)
|
||||
|
||||
assert payload["labels"] == [42]
|
||||
assert payload["title"] == "Test issue"
|
||||
|
||||
@patch('issue_core.backends.gitea.backend.requests.Session')
|
||||
def test_test_connection_success(self, mock_session_class):
|
||||
"""Test test_connection method works correctly."""
|
||||
|
||||
Reference in New Issue
Block a user