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:
Marcus Valtonen Örnhag
2025-04-07 23:35:25 +02:00
committed by GitHub
parent 0767030997
commit 2331079c0f
8 changed files with 1246 additions and 898 deletions

File diff suppressed because one or more lines are too long

View File

@@ -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={