mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-05 00:15:51 +01:00
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
|
from unittest.mock import Mock
|
||
|
|
||
|
from fastapi.testclient import TestClient
|
||
|
|
||
|
from frigate.models import Event, Recordings, ReviewSegment
|
||
|
from frigate.stats.emitter import StatsEmitter
|
||
|
from frigate.test.http_api.base_http_test import BaseTestHttp
|
||
|
|
||
|
|
||
|
class TestHttpApp(BaseTestHttp):
|
||
|
def setUp(self):
|
||
|
super().setUp([Event, Recordings, ReviewSegment])
|
||
|
self.app = super().create_app()
|
||
|
|
||
|
####################################################################################################################
|
||
|
################################### GET /stats Endpoint #########################################################
|
||
|
####################################################################################################################
|
||
|
def test_stats_endpoint(self):
|
||
|
stats = Mock(spec=StatsEmitter)
|
||
|
stats.get_latest_stats.return_value = self.test_stats
|
||
|
app = super().create_app(stats)
|
||
|
|
||
|
with TestClient(app) as client:
|
||
|
response = client.get("/stats")
|
||
|
response_json = response.json()
|
||
|
assert response_json == self.test_stats
|