Files
facefusion/tests/test_api_ping.py
T
Henry Ruhs 3d2b0c222c feat/ping-endpoint (#1001)
* api: add WebSocket /ping endpoint and update session guard to support WebSocket subprotocol auth; add tests (test_api_ping.py)

* Initial websocket support using ping

* Initial websocket support using ping

* Initial websocket support using ping

* Combine imports
2026-03-17 14:01:49 +01:00

33 lines
822 B
Python

from typing import Iterator
import pytest
from starlette.testclient import TestClient
from facefusion import metadata, session_manager
from facefusion.apis.core import create_api
@pytest.fixture(scope = 'module')
def test_client() -> Iterator[TestClient]:
with TestClient(create_api()) as test_client:
yield test_client
@pytest.fixture(scope = 'function', autouse = True)
def before_each() -> None:
session_manager.SESSIONS.clear()
def test_ping(test_client : TestClient) -> None:
create_session_response = test_client.post('/session', json =
{
'client_version': metadata.get('version')
})
create_session_body = create_session_response.json()
with test_client.websocket_connect('/ping', subprotocols =
[
'access_token.' + create_session_body.get('access_token')
]) as websocket:
assert websocket