Files
facefusion/tests/test_api_capabilities.py
T
Henry Ruhs 76c413a2c1 Refactor/ffmpeg less stream (#1092)
* remove ffmpeg from stream to use opus and vpx, add bunch of todos

* fix testing

* improve download checkout

* fix datachannel download, fix super dirty test clients - setup logic does not belong there

* fix testing
2026-05-11 16:36:23 +02:00

60 lines
1.5 KiB
Python

from argparse import ArgumentParser
from typing import Iterator
import pytest
from starlette.testclient import TestClient
from facefusion import capability_store, session_manager
from facefusion.apis.core import create_api
@pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None:
program = ArgumentParser()
capability_store.register_capability_set(
[
program.add_argument(
'--source-paths',
nargs = '+'
)
],
scopes = [ 'api' ]
)
capability_store.register_capability_set(
[
program.add_argument(
'--output-format',
default = 'mp4',
choices = [ 'mp4', 'mkv', 'webm' ]
)
],
scopes = [ 'api' ]
)
@pytest.fixture(scope = 'function', autouse = True)
def before_each() -> None:
session_manager.SESSIONS.clear()
@pytest.fixture(scope = 'module')
def test_client() -> Iterator[TestClient]:
with TestClient(create_api()) as test_client:
yield test_client
def test_get_capabilities(test_client : TestClient) -> None:
capabilities_response = test_client.get('/capabilities')
capabilities_body = capabilities_response.json()
assert capabilities_response.status_code == 200
assert 'mp3' in capabilities_body.get('formats').get('audio')
assert 'jpeg' in capabilities_body.get('formats').get('image')
assert 'mp4' in capabilities_body.get('formats').get('video')
assert capabilities_body.get('arguments').get('source_paths').get('default') is None
assert capabilities_body.get('arguments').get('output_format').get('choices') == [ 'mp4', 'mkv', 'webm' ]