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