All checks were successful
Container Image / build-and-push (push) Successful in 29s
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
import json
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_call_accepts_integration_id_alias():
|
|
from src.tools import system
|
|
|
|
integrations = [
|
|
{
|
|
"id": "f9909f22dc17",
|
|
"name": "Gitea",
|
|
"enabled": True,
|
|
"base_url": "https://git.example.test",
|
|
}
|
|
]
|
|
|
|
with (
|
|
patch("src.integrations.load_integrations", return_value=integrations),
|
|
patch("src.integrations.execute_api_call", new_callable=AsyncMock) as execute,
|
|
):
|
|
execute.return_value = {"output": "ok", "exit_code": 0}
|
|
|
|
result = await system.do_api_call(json.dumps({
|
|
"integration_id": "f9909f22dc17",
|
|
"method": "GET",
|
|
"path": "/api/v1/user/repos",
|
|
}))
|
|
|
|
assert result == {"output": "ok", "exit_code": 0}
|
|
execute.assert_awaited_once_with(
|
|
"f9909f22dc17",
|
|
"GET",
|
|
"/api/v1/user/repos",
|
|
params=None,
|
|
body=None,
|
|
extra_headers=None,
|
|
)
|