mirror of
https://github.com/facefusion/facefusion.git
synced 2026-04-22 17:36:16 +02:00
3d2b0c222c
* 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
33 lines
822 B
Python
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
|