Accept integration_id for api_call
All checks were successful
Container Image / build-and-push (push) Successful in 29s
All checks were successful
Container Image / build-and-push (push) Successful in 29s
This commit is contained in:
40
tests/test_api_call_integration_id_alias.py
Normal file
40
tests/test_api_call_integration_id_alias.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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,
|
||||
)
|
||||
Reference in New Issue
Block a user