mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-18 06:47:13 +02:00
improve test
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from pytest_mock import MockerFixture
|
||||||
from starlette.testclient import TestClient
|
from starlette.testclient import TestClient
|
||||||
|
|
||||||
from facefusion import metadata, session_manager
|
from facefusion import metadata, session_manager
|
||||||
@@ -18,6 +19,65 @@ def before_each() -> None:
|
|||||||
session_manager.SESSIONS.clear()
|
session_manager.SESSIONS.clear()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope = 'function', autouse = True)
|
||||||
|
def mock_detect_execution_devices(mocker : MockerFixture) -> None:
|
||||||
|
mocker.patch('facefusion.system.detect_execution_devices', return_value =
|
||||||
|
[
|
||||||
|
{
|
||||||
|
'driver_version': '555.42',
|
||||||
|
'framework':
|
||||||
|
{
|
||||||
|
'name': 'CUDA',
|
||||||
|
'version': '12.5'
|
||||||
|
},
|
||||||
|
'product':
|
||||||
|
{
|
||||||
|
'vendor': 'NVIDIA',
|
||||||
|
'name': 'RTX 4090'
|
||||||
|
},
|
||||||
|
'video_memory':
|
||||||
|
{
|
||||||
|
'total':
|
||||||
|
{
|
||||||
|
'value': 24,
|
||||||
|
'unit': 'GB'
|
||||||
|
},
|
||||||
|
'free':
|
||||||
|
{
|
||||||
|
'value': 20,
|
||||||
|
'unit': 'GB'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'temperature':
|
||||||
|
{
|
||||||
|
'gpu':
|
||||||
|
{
|
||||||
|
'value': 45,
|
||||||
|
'unit': 'C'
|
||||||
|
},
|
||||||
|
'memory':
|
||||||
|
{
|
||||||
|
'value': 0,
|
||||||
|
'unit': 'C'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'utilization':
|
||||||
|
{
|
||||||
|
'gpu':
|
||||||
|
{
|
||||||
|
'value': 30,
|
||||||
|
'unit': '%'
|
||||||
|
},
|
||||||
|
'memory':
|
||||||
|
{
|
||||||
|
'value': 15,
|
||||||
|
'unit': '%'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def test_get_metrics(test_client : TestClient) -> None:
|
def test_get_metrics(test_client : TestClient) -> None:
|
||||||
get_metrics_response = test_client.get('/metrics')
|
get_metrics_response = test_client.get('/metrics')
|
||||||
|
|
||||||
@@ -35,8 +95,10 @@ def test_get_metrics(test_client : TestClient) -> None:
|
|||||||
})
|
})
|
||||||
get_metrics_body = get_metrics_response.json()
|
get_metrics_body = get_metrics_response.json()
|
||||||
|
|
||||||
assert 'execution_devices' in get_metrics_body
|
|
||||||
assert get_metrics_response.status_code == 200
|
assert get_metrics_response.status_code == 200
|
||||||
|
assert get_metrics_body.get('execution_devices')[0].get('driver_version') == '555.42'
|
||||||
|
assert get_metrics_body.get('execution_devices')[0].get('product').get('name') == 'RTX 4090'
|
||||||
|
assert get_metrics_body.get('execution_devices')[0].get('video_memory').get('total').get('value') == 24
|
||||||
|
|
||||||
|
|
||||||
def test_websocket_metrics(test_client : TestClient) -> None:
|
def test_websocket_metrics(test_client : TestClient) -> None:
|
||||||
@@ -52,4 +114,6 @@ def test_websocket_metrics(test_client : TestClient) -> None:
|
|||||||
]) as websocket:
|
]) as websocket:
|
||||||
metrics_set = websocket.receive_json()
|
metrics_set = websocket.receive_json()
|
||||||
|
|
||||||
assert 'execution_devices' in metrics_set
|
assert metrics_set.get('execution_devices')[0].get('driver_version') == '555.42'
|
||||||
|
assert metrics_set.get('execution_devices')[0].get('product').get('name') == 'RTX 4090'
|
||||||
|
assert metrics_set.get('execution_devices')[0].get('video_memory').get('total').get('value') == 24
|
||||||
|
|||||||
Reference in New Issue
Block a user