Example #1
0
    def test_transport__setup(self, device, loop, sleep, mode, status, reset):
        unit = AsyncioTransport(device, loop, callback=mock.Mock())
        # reset mocks which have been 'called' by the constructor
        device.reset_mock()
        loop.reset_mock()

        # run: exaust the coroutine generator
        execute_coroutine(unit._setup())

        loop.add_reader.assert_called_with(device.fd, unit.read)
        reset.assert_called_once_with()
        sleep.assert_has_calls((mock.ANY, mock.ANY))
        slept_time = sleep.call_args[0][0]
        # by spec it needs to be between 0.5ms and 9000ms
        self.assertGreater(slept_time, 0.05)
        self.assertLess(slept_time, 9)
        mode.assert_called_once_with()
        status.assert_called_once_with()
Example #2
0
    def test_transport__setup(self, device, loop, sleep, mode, status, reset):
        unit = AsyncioTransport(device, loop, callback=mock.Mock())
        # reset mocks which have been 'called' by the constructor
        device.reset_mock()
        loop.reset_mock()

        # run: exaust the coroutine generator
        execute_coroutine(unit._setup())

        loop.add_reader.assert_called_with(device.fd, unit.read)
        reset.assert_called_once_with()
        sleep.assert_has_calls((mock.ANY, mock.ANY))
        slept_time = sleep.call_args[0][0]
        # by spec it needs to be between 0.5ms and 9000ms
        self.assertGreater(slept_time, 0.05)
        self.assertLess(slept_time, 9)
        mode.assert_called_once_with()
        status.assert_called_once_with()