From 2195636940cfd7edd9ac0fa2600dfe8960b8bd11 Mon Sep 17 00:00:00 2001 From: voluntas Date: Mon, 21 Oct 2024 22:42:21 +0900 Subject: [PATCH] =?UTF-8?q?test=5Fabort.py=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/api.py | 9 +++++++++ tests/test_abort.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/test_abort.py diff --git a/tests/api.py b/tests/api.py index 89d42f5..3bf142e 100644 --- a/tests/api.py +++ b/tests/api.py @@ -1,5 +1,14 @@ import httpx + +def disconnect_channel_api(url: str, channel_id: str) -> httpx.Response: + headers = { + "Content-Type": "application/json", + "x-sora-target": "Sora_20151104.DisconnectChannel", + } + return httpx.post(url, headers=headers, json={"channel_id": channel_id}, follow_redirects=True) + + def disconnect_connection_api(url: str, channel_id: str, connection_id: str) -> httpx.Response: headers = { "Content-Type": "application/json", diff --git a/tests/test_abort.py b/tests/test_abort.py new file mode 100644 index 0000000..df38482 --- /dev/null +++ b/tests/test_abort.py @@ -0,0 +1,37 @@ +import sys +import uuid + +from api import disconnect_channel_api +from client import SoraClient, SoraRole + + +def test_abort(setup): + """ + abort させるためのテスト + """ + signaling_urls = setup.get("signaling_urls") + channel_id_prefix = setup.get("channel_id_prefix") + metadata = setup.get("metadata") + + channel_id = f"{channel_id_prefix}_{__name__}_{sys._getframe().f_code.co_name}_{uuid.uuid4()}" + + conn1 = SoraClient( + signaling_urls, + SoraRole.SENDONLY, + channel_id, + audio=True, + video=True, + metadata=metadata, + ).connect(fake_audio=True, fake_video=True) + + conn2 = SoraClient( + signaling_urls, + SoraRole.RECVONLY, + channel_id, + audio=True, + video=True, + metadata=metadata, + ).connect() + + response = disconnect_channel_api(signaling_urls, channel_id) + assert response.status_code == 200, [response.text]