Skip to content

Commit

Permalink
Fix python tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaheux committed Dec 22, 2023
1 parent df17910 commit 0119be3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DisconnectedDataChannelClientTestCase(FailureTestCase):
def setUp(self):
super(DisconnectedDataChannelClientTestCase, self).setUp()
self._client1 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', ""),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', ""),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

Expand Down Expand Up @@ -51,7 +51,7 @@ def tearDownClass(cls):
def setUp(self):
super(WrongPasswordDataChannelClientTestCase, self).setUp()
self._client1 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', ''),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', ''),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

Expand Down Expand Up @@ -102,7 +102,7 @@ def tearDownClass(cls):
def setUp(self):
super(SingleDataChannelClientTestCase, self).setUp()
self._client1 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', 'abc'),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

Expand Down Expand Up @@ -152,17 +152,17 @@ def on_signaling_connection_opened():
awaiter.done()

self._client1 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', 'abc'),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

self._client2 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c2', 'cd2', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c2', 'cd2', 'chat', 'abc'),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

self._client3 = webrtc.DataChannelClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c3', 'cd3', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c3', 'cd3', 'chat', 'abc'),
DEFAULT_WEBRTC_CONFIGURATION,
webrtc.DataChannelConfiguration.create())

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
python-socketio==5.0.4
websocket-client==1.7.0
requests

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def on_signaling_connection_opened():
setup_awaiter.done()

client1 = webrtc.StreamClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', 'abc'),
webrtc.WebrtcConfiguration.create(),
webrtc.VideoStreamConfiguration.create(),
video_source1)

client2 = webrtc.StreamClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c2', 'cd2', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c2', 'cd2', 'chat', 'abc'),
webrtc.WebrtcConfiguration.create(),
webrtc.VideoStreamConfiguration.create(),
video_source2)
Expand Down Expand Up @@ -129,7 +129,7 @@ def on_audio_frame_received(client, data, sample_rate, number_of_channels, numbe

def test_mute_methods__should_set_the_flag_accordingly(self):
client = webrtc.StreamClient(
webrtc.SignalingServerConfiguration.create('http://localhost:8080', 'c1', 'cd1', 'chat', 'abc'),
webrtc.SignalingServerConfiguration.create_with_data('ws://localhost:8080/signaling', 'c1', 'cd1', 'chat', 'abc'),
webrtc.WebrtcConfiguration.create(),
webrtc.VideoStreamConfiguration.create())

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import threading

import websocket

from callback_awaiter import CallbackAwaiter
from failure_test_case import FailureTestCase
from signaling_server_runner import SignalingServerRunner


class WebSocketInactiveClientTestCase(FailureTestCase):
@classmethod
def setUpClass(cls):
super(WebSocketInactiveClientTestCase, cls).setUpClass()
cls._signaling_server_runner = SignalingServerRunner()

@classmethod
def tearDownClass(cls):
cls._signaling_server_runner.close()
super(WebSocketInactiveClientTestCase, cls).tearDownClass()

def test_socketio_inactive_is_disconnected_after_timeout(self):
awaiter = CallbackAwaiter(2, 15)

def on_open(ws):
awaiter.done()

def on_message(ws, message):
pass

def on_error(ws, error):
awaiter.done()
awaiter.done()
self.add_failure(error)

def on_close(ws, close_status_code, close_msg):
awaiter.done()

websocket.enableTrace(True)
ws = websocket.WebSocketApp('ws://localhost:8080/signaling',
on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close)

thread = threading.Thread(target=ws.run_forever)
thread.start()

awaiter.wait()
ws.close()

0 comments on commit 0119be3

Please sign in to comment.