-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file component #24
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
042eef9
Add file component
roznawsk a2bb59c
Allow for ignoring file tests locally (#25)
roznawsk 4b177b7
Test components using function
roznawsk 4987e00
revert match
roznawsk 48c6244
Add volume in tests
roznawsk 0fa12dc
Poetry script for local tests
roznawsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import os | ||
import uuid | ||
from dataclasses import dataclass | ||
|
||
import pytest | ||
|
||
|
@@ -41,10 +42,28 @@ | |
CODEC_H264 = "h264" | ||
|
||
HLS_OPTIONS = ComponentOptionsHLS() | ||
HLS_PROPERTIES = ComponentPropertiesHLS( | ||
low_latency=False, | ||
persistent=False, | ||
playable=False, | ||
subscribe_mode=ComponentPropertiesHLSSubscribeMode("auto"), | ||
target_window_duration=None, | ||
) | ||
HLS_PROPERTIES.additional_properties = {"s3": None} | ||
|
||
RTSP_OPTIONS = ComponentOptionsRTSP( | ||
source_uri="rtsp://ef36c6dff23ecc5bbe311cc880d95dc8.se:2137/does/not/matter" | ||
) | ||
RTSP_PROPERTIES = ComponentPropertiesRTSP( | ||
source_uri=RTSP_OPTIONS.source_uri, | ||
keep_alive_interval=15000, | ||
reconnect_delay=15000, | ||
rtp_port=20000, | ||
pierce_nat=True, | ||
) | ||
|
||
FILE_OPTIONS = ComponentOptionsFile(file_path="video.h264") | ||
FILE_PROPERTIES = ComponentPropertiesFile(file_path=FILE_OPTIONS.file_path) | ||
|
||
|
||
class TestAuthentication: | ||
|
@@ -192,70 +211,49 @@ def test_invalid(self, room_api: RoomApi): | |
room_api.get_room("invalid_id") | ||
|
||
|
||
class TestAddComponent: | ||
def test_with_options_hls(self, room_api: RoomApi): | ||
_, room = room_api.create_room(video_codec=CODEC_H264) | ||
@dataclass | ||
class ComponentTestData: | ||
component: any | ||
type: str | ||
options: any | ||
properties: any | ||
|
||
response = room_api.add_component(room.id, options=HLS_OPTIONS) | ||
|
||
component = room_api.get_room(room.id).components[0] | ||
class TestAddComponent: | ||
def test_with_options_hls(self, room_api): | ||
data = ComponentTestData(ComponentHLS, "hls", HLS_OPTIONS, HLS_PROPERTIES) | ||
self._test_component(room_api, data) | ||
|
||
properties = ComponentPropertiesHLS( | ||
low_latency=False, | ||
persistent=False, | ||
playable=False, | ||
subscribe_mode=ComponentPropertiesHLSSubscribeMode("auto"), | ||
target_window_duration=None, | ||
) | ||
properties.additional_properties = {"s3": None} | ||
component_hls = ComponentHLS(id=component.id, type="hls", properties=properties) | ||
def test_with_options_rtsp(self, room_api): | ||
data = ComponentTestData(ComponentRTSP, "rtsp", RTSP_OPTIONS, RTSP_PROPERTIES) | ||
self._test_component(room_api, data) | ||
|
||
assert response == component_hls | ||
assert component == component_hls | ||
@pytest.mark.file_component_sources | ||
def test_with_options_file(self, room_api): | ||
data = ComponentTestData(ComponentFile, "file", FILE_OPTIONS, FILE_PROPERTIES) | ||
self._test_component(room_api, data) | ||
|
||
def test_with_options_rtsp(self, room_api: RoomApi): | ||
def test_invalid_type(self, room_api: RoomApi): | ||
_, room = room_api.create_room(video_codec=CODEC_H264) | ||
|
||
response = room_api.add_component(room.id, options=RTSP_OPTIONS) | ||
component = room_api.get_room(room.id).components[0] | ||
|
||
component_rtsp = ComponentRTSP( | ||
id=component.id, | ||
type="rtsp", | ||
properties=ComponentPropertiesRTSP( | ||
source_uri=RTSP_OPTIONS.source_uri, | ||
keep_alive_interval=RTSP_OPTIONS.keep_alive_interval, | ||
reconnect_delay=RTSP_OPTIONS.reconnect_delay, | ||
rtp_port=RTSP_OPTIONS.rtp_port, | ||
pierce_nat=RTSP_OPTIONS.pierce_nat, | ||
), | ||
) | ||
|
||
assert response == component_rtsp | ||
assert component == component_rtsp | ||
|
||
def test_with_options_file(self, room_api: RoomApi): | ||
_, room = room_api.create_room() | ||
with pytest.raises(ValueError): | ||
room_api.add_component(room.id, options=PeerOptionsWebRTC()) | ||
|
||
response = room_api.add_component(room.id, options=FILE_OPTIONS) | ||
def _test_component(self, room_api: RoomApi, test_data: ComponentTestData): | ||
_, room = room_api.create_room(video_codec=CODEC_H264) | ||
|
||
response = room_api.add_component(room.id, options=test_data.options) | ||
component = room_api.get_room(room.id).components[0] | ||
|
||
component_file = ComponentFile( | ||
component_file = test_data.component( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be renamed? |
||
id=component.id, | ||
type="file", | ||
properties=ComponentPropertiesFile(file_path=FILE_OPTIONS.file_path), | ||
type=test_data.type, | ||
properties=test_data.properties, | ||
) | ||
|
||
assert response == component_file | ||
assert component == component_file | ||
|
||
def test_invalid_type(self, room_api: RoomApi): | ||
_, room = room_api.create_room(video_codec=CODEC_H264) | ||
|
||
with pytest.raises(ValueError): | ||
room_api.add_component(room.id, options=PeerOptionsWebRTC()) | ||
|
||
|
||
class TestDeleteComponent: | ||
def test_valid_component(self, room_api: RoomApi): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should create a poetry script for that something like
test.local
or something like that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do