-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add signaling and moderation endpoints, start live captions
- Loading branch information
Showing
7 changed files
with
279 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from .enums import LanguageCode | ||
|
||
|
||
class CaptionsOptions(BaseModel): | ||
"""The Options to send captions. | ||
Args: | ||
session_id (str): The session ID. | ||
token (str): The token. | ||
language_code (LanguageCode, Optional): The language code. | ||
max_duration (int, Optional): The maximum duration. | ||
partial_captions (bool, Optional): The partial captions. | ||
status_callback_url (str, Optional): The status callback URL. | ||
""" | ||
|
||
session_id: str = Field(..., serialization_alias='sessionId') | ||
token: str | ||
language_code: Optional[LanguageCode] = Field( | ||
None, serialization_alias='languageCode' | ||
) | ||
max_duration: Optional[int] = Field( | ||
None, le=300, ge=14400, serialization_alias='maxDuration' | ||
) | ||
partial_captions: Optional[bool] = Field(None, serialization_alias='partialCaptions') | ||
status_callback_url: Optional[str] = Field( | ||
None, min_length=15, max_length=2048, serialization_alias='statusCallbackUrl' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from os.path import abspath | ||
|
||
import responses | ||
from vonage_http_client import HttpClient | ||
from vonage_video.models.captions import CaptionsOptions | ||
from vonage_video.video import Video | ||
|
||
from testutils import build_response, get_mock_jwt_auth | ||
|
||
path = abspath(__file__) | ||
|
||
|
||
video = Video(HttpClient(get_mock_jwt_auth())) | ||
|
||
|
||
@responses.activate | ||
def test_start_captions(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/captions', | ||
'start_captions.json', | ||
202, | ||
) | ||
|
||
options = CaptionsOptions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from os.path import abspath | ||
|
||
import responses | ||
from vonage_http_client import HttpClient | ||
from vonage_video.video import Video | ||
|
||
from testutils import build_response, get_mock_jwt_auth | ||
|
||
path = abspath(__file__) | ||
|
||
|
||
video = Video(HttpClient(get_mock_jwt_auth())) | ||
|
||
|
||
@responses.activate | ||
def test_disconnect_client(): | ||
build_response( | ||
path, | ||
'DELETE', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/connection/test_connection_id', | ||
status_code=204, | ||
) | ||
|
||
video.disconnect_client( | ||
session_id='test_session_id', connection_id='test_connection_id' | ||
) | ||
|
||
assert responses.calls[0].response.status_code == 204 | ||
|
||
|
||
@responses.activate | ||
def test_mute_stream(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/stream/test_stream_id/mute', | ||
) | ||
|
||
video.mute_stream(session_id='test_session_id', stream_id='test_stream_id') | ||
|
||
assert responses.calls[0].response.status_code == 200 | ||
|
||
|
||
@responses.activate | ||
def test_mute_all_streams(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/mute', | ||
) | ||
|
||
video.mute_all_streams(session_id='test_session_id') | ||
assert responses.calls[0].response.status_code == 200 | ||
|
||
video.disable_mute_all_streams(session_id='test_session_id') | ||
assert responses.calls[1].response.status_code == 200 | ||
|
||
|
||
@responses.activate | ||
def test_mute_all_streams_excluded_stream_ids(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/mute', | ||
) | ||
|
||
video.mute_all_streams( | ||
session_id='test_session_id', excluded_stream_ids=['test_stream_id'] | ||
) | ||
assert responses.calls[0].response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from os.path import abspath | ||
|
||
import responses | ||
from vonage_http_client import HttpClient | ||
from vonage_video.models.signal import SignalData | ||
from vonage_video.video import Video | ||
|
||
from testutils import build_response, get_mock_jwt_auth | ||
|
||
path = abspath(__file__) | ||
|
||
|
||
video = Video(HttpClient(get_mock_jwt_auth())) | ||
|
||
|
||
@responses.activate | ||
def test_send_signal_all(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/signal', | ||
status_code=204, | ||
) | ||
|
||
video.send_signal( | ||
session_id='test_session_id', data=SignalData(type='msg', data='Hello, World!') | ||
) | ||
|
||
assert responses.calls[0].response.status_code == 204 | ||
|
||
|
||
@responses.activate | ||
def test_send_signal_to_connection_id(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/session/test_session_id/connection/test_connection_id/signal', | ||
status_code=204, | ||
) | ||
|
||
video.send_signal( | ||
session_id='test_session_id', | ||
data=SignalData(type='msg', data='Hello, World!'), | ||
connection_id='test_connection_id', | ||
) | ||
|
||
assert responses.calls[0].response.status_code == 204 |