mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Introduce unit tests (#248)
* Proof-of-concept: unittests * Add pytest-asyncio dep * Import Body from stream * Add test for allow_extra_tracks * Cleanup decorators * add test to linting * fix ruff issues * Run formatter * fix * Dont test every python version --------- Co-authored-by: Marcus Valtonen Örnhag <marcus.valtonen.ornhag@ericsson.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0767030997
commit
2331079c0f
File diff suppressed because one or more lines are too long
@@ -106,6 +106,7 @@ class WebRTCConnectionMixin:
|
||||
def clean_up(self, webrtc_id: str):
|
||||
self.handlers.pop(webrtc_id, None)
|
||||
self.connection_timeouts.pop(webrtc_id, None)
|
||||
self.pcs.pop(webrtc_id, None)
|
||||
connection = self.connections.pop(webrtc_id, [])
|
||||
for conn in connection:
|
||||
if isinstance(conn, AudioCallback):
|
||||
@@ -229,7 +230,18 @@ class WebRTCConnectionMixin:
|
||||
content={"status": "failed", "meta": {"error": "connection_closed"}},
|
||||
)
|
||||
|
||||
if len(self.connections) >= cast(int, self.concurrency_limit):
|
||||
if body["webrtc_id"] in self.connections:
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={
|
||||
"status": "failed",
|
||||
"meta": {
|
||||
"error": "connection_already_exists",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if len(self.pcs) >= cast(int, self.concurrency_limit):
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={
|
||||
|
||||
Reference in New Issue
Block a user