From f59bf04bc2438c543ea1f9799e5506f13a4add68 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Fri, 9 Jan 2026 15:34:29 +0100 Subject: [PATCH] Minor cleanup --- facefusion/apis/asset_store.py | 2 +- facefusion/apis/endpoints/state.py | 12 +++++------- tests/test_api_state.py | 6 +++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/facefusion/apis/asset_store.py b/facefusion/apis/asset_store.py index 36fd3955..a9f0c2fc 100644 --- a/facefusion/apis/asset_store.py +++ b/facefusion/apis/asset_store.py @@ -1,7 +1,7 @@ import uuid from typing import Dict, Optional -ASSET_STORE: Dict[str, Dict[str, str]] = {} +ASSET_STORE : Dict[str, Dict[str, str]] = {} def get_asset(asset_id : str) -> Optional[Dict[str, str]]: diff --git a/facefusion/apis/endpoints/state.py b/facefusion/apis/endpoints/state.py index d186a496..5875f5a0 100644 --- a/facefusion/apis/endpoints/state.py +++ b/facefusion/apis/endpoints/state.py @@ -13,15 +13,13 @@ async def get_state(request : Request) -> JSONResponse: async def set_state(request : Request) -> JSONResponse: action = request.query_params.get('action') + asset_type = request.query_params.get('type') - if action == 'select': - asset_type = request.query_params.get('type') + if action == 'select' and asset_type == 'source': + return await select_source(request) - if asset_type == 'source': - return await select_source(request) - - if asset_type == 'target': - return await select_target(request) + if action == 'select' and asset_type == 'target': + return await select_target(request) body = await request.json() api_args = args_store.get_api_args() diff --git a/tests/test_api_state.py b/tests/test_api_state.py index 4bad1270..b2cd0fe0 100644 --- a/tests/test_api_state.py +++ b/tests/test_api_state.py @@ -85,7 +85,11 @@ def test_set_state(test_client : TestClient) -> None: def test_select_source_assets(test_client : TestClient) -> None: - asset_ids = [ asset_store.register_asset('/path/to/source1.jpg'), asset_store.register_asset('/path/to/source2.jpg') ] + asset_ids =\ + [ + asset_store.register_asset('/path/to/source1.jpg'), + asset_store.register_asset('/path/to/source2.jpg') + ] select_response = test_client.put('/state?action=select&type=source', json = {