fix(bitbucket): use the configured base_url

Build the file and listing URLs from the configured base_url instead of the hardcoded api.bitbucket.org host, and cover the configured URL through the HTTP boundary in the unit test.
This commit is contained in:
HhH666-ux 2026-11-06 23:05:58 +08:00
parent dddbaa803d
commit 514118e916
2 changed files with 22 additions and 1 deletions

View file

@ -80,7 +80,7 @@ class BitBucketClient:
self.repository = config.get("repository")
self.access_token = config.get("access_token")
self.branch = config.get("branch", "main")
self.base_url = config.get("", "https://api.bitbucket.org/2.0")
self.base_url = config.get("base_url", "https://api.bitbucket.org/2.0")
self.auth_method = config.get("auth_method", "token")
self.username = config.get("username")

View file

@ -2,7 +2,9 @@ import json
import re
from unittest.mock import MagicMock, patch
import httpx
import pytest
import respx
from litellm.integrations.bitbucket.bitbucket_client import BitBucketClient
@ -65,6 +67,25 @@ def test_bitbucket_client_initialization():
assert client_basic.username == "test-user"
def test_bitbucket_client_uses_configured_base_url():
config = {
"workspace": "test-workspace",
"repository": "test-repo",
"access_token": "test-token",
"base_url": "https://bitbucket.example.com/2.0",
}
with respx.mock:
respx.get(
"https://bitbucket.example.com/2.0/repositories/test-workspace/test-repo/src/main/prompts/test.prompt"
).mock(return_value=httpx.Response(200, text="prompt", headers={"content-type": "text/plain"}))
client = BitBucketClient(config)
content = client.get_file_content("prompts/test.prompt")
assert content == "prompt"
def test_bitbucket_client_missing_required_fields():
"""Test BitBucketClient initialization with missing required fields."""
with pytest.raises(