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(): 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( 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_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(): 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(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')
async def test_connect_fail(self): gatherer_1 = RTCIceGatherer() transport_1 = RTCIceTransport(gatherer_1) gatherer_2 = RTCIceGatherer() transport_2 = RTCIceTransport(gatherer_2) # gather candidates await asyncio.gather(gatherer_1.gather(), gatherer_2.gather()) for candidate in gatherer_2.getLocalCandidates(): await transport_1.addRemoteCandidate(candidate) for candidate in gatherer_1.getLocalCandidates(): await transport_2.addRemoteCandidate(candidate) self.assertEqual(transport_1.state, "new") self.assertEqual(transport_2.state, "new") # connect await transport_2.stop() await transport_1.start(gatherer_2.getLocalParameters()) self.assertEqual(transport_1.state, "failed") self.assertEqual(transport_2.state, "closed") # cleanup await asyncio.gather(transport_1.stop(), transport_2.stop()) self.assertEqual(transport_1.state, "closed") self.assertEqual(transport_2.state, "closed")