Exemplo n.º 1
0
    def test_connect_when_closed(self):
        gatherer = RTCIceGatherer()
        transport = RTCIceTransport(gatherer)

        # stop transport
        run(transport.stop())
        self.assertEqual(transport.state, "closed")

        # try to start it
        with self.assertRaises(InvalidStateError) as cm:
            run(
                transport.start(
                    RTCIceParameters(usernameFragment="foo", password="******")))
        self.assertEqual(str(cm.exception), "RTCIceTransport is closed")
Exemplo n.º 2
0
    def test_send_connection_error(self):
        gatherer = RTCIceGatherer()
        transport = RTCIceTransport(gatherer)
        self.assertEqual(transport.state, "new")

        # fake connection
        gatherer._connection.connect = noop
        run(
            transport.start(
                RTCIceParameters(usernameFragment="foo", password="******")))
        self.assertEqual(transport.state, "completed")

        with self.assertRaises(ConnectionError):
            run(transport._send(b"foo"))
        self.assertEqual(transport.state, "failed")
Exemplo n.º 3
0
    def test_send_connection_error(self):
        gatherer = RTCIceGatherer()
        transport = RTCIceTransport(gatherer)
        self.assertEqual(transport.state, 'new')

        # fake connection
        gatherer._connection.connect = noop
        run(
            transport.start(
                RTCIceParameters(usernameFragment='foo', password='******')))
        self.assertEqual(transport.state, 'completed')

        with self.assertRaises(ConnectionError):
            run(transport._send(b'foo'))
        self.assertEqual(transport.state, 'failed')
Exemplo n.º 4
0
    async def test_connection_closed(self):
        gatherer = RTCIceGatherer()

        # mock out methods
        gatherer._connection.connect = mock_connect
        gatherer._connection.get_event = mock_get_event

        transport = RTCIceTransport(gatherer)
        self.assertEqual(transport.state, "new")

        await transport.start(RTCIceParameters(usernameFragment="foo", password="******"))
        self.assertEqual(transport.state, "completed")

        await asyncio.sleep(1)
        self.assertEqual(transport.state, "failed")

        await transport.stop()
        self.assertEqual(transport.state, "closed")