mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-07 11:07:53 +02:00
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
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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
|
||||
Reference in New Issue
Block a user