def test_connect_fail(self): gatherer_1 = RTCIceGatherer() transport_1 = RTCIceTransport(gatherer_1) gatherer_2 = RTCIceGatherer() transport_2 = RTCIceTransport(gatherer_2) # gather candidates run(asyncio.gather(gatherer_1.gather(), gatherer_2.gather())) for candidate in gatherer_2.getLocalCandidates(): run(transport_1.addRemoteCandidate(candidate)) for candidate in gatherer_1.getLocalCandidates(): run(transport_2.addRemoteCandidate(candidate)) self.assertEqual(transport_1.state, "new") self.assertEqual(transport_2.state, "new") # connect run(transport_2.stop()) run(transport_1.start(gatherer_2.getLocalParameters())) self.assertEqual(transport_1.state, "failed") self.assertEqual(transport_2.state, "closed") # cleanup run(asyncio.gather(transport_1.stop(), transport_2.stop())) self.assertEqual(transport_1.state, "closed") self.assertEqual(transport_2.state, "closed")
def test_connect(self): gatherer_1 = RTCIceGatherer() transport_1 = RTCIceTransport(gatherer_1) gatherer_2 = RTCIceGatherer() transport_2 = RTCIceTransport(gatherer_2) # gather candidates run(asyncio.gather(gatherer_1.gather(), gatherer_2.gather())) for candidate in gatherer_2.getLocalCandidates(): transport_1.addRemoteCandidate(candidate) for candidate in gatherer_1.getLocalCandidates(): transport_2.addRemoteCandidate(candidate) self.assertEqual(transport_1.state, 'new') self.assertEqual(transport_2.state, 'new') # connect run( asyncio.gather(transport_1.start(gatherer_2.getLocalParameters()), transport_2.start(gatherer_1.getLocalParameters()))) self.assertEqual(transport_1.state, 'completed') self.assertEqual(transport_2.state, 'completed') # cleanup run(asyncio.gather(transport_1.stop(), transport_2.stop())) self.assertEqual(transport_1.state, 'closed') self.assertEqual(transport_2.state, 'closed')
def test_construct(self): gatherer = RTCIceGatherer() connection = RTCIceTransport(gatherer) self.assertEqual(connection.state, 'new') self.assertEqual(connection.getRemoteCandidates(), []) candidate = RTCIceCandidate(component=1, foundation='0', ip='192.168.99.7', port=33543, priority=2122252543, protocol='UDP', type='host') # add candidate connection.addRemoteCandidate(candidate) self.assertEqual(connection.getRemoteCandidates(), [candidate]) # end-of-candidates connection.addRemoteCandidate(None) self.assertEqual(connection.getRemoteCandidates(), [candidate])
def test_construct(self): gatherer = RTCIceGatherer() connection = RTCIceTransport(gatherer) self.assertEqual(connection.state, "new") self.assertEqual(connection.getRemoteCandidates(), []) candidate = RTCIceCandidate( component=1, foundation="0", ip="192.168.99.7", port=33543, priority=2122252543, protocol="UDP", type="host", ) # add candidate run(connection.addRemoteCandidate(candidate)) self.assertEqual(connection.getRemoteCandidates(), [candidate]) # end-of-candidates run(connection.addRemoteCandidate(None)) self.assertEqual(connection.getRemoteCandidates(), [candidate])