Esempio n. 1
0
 def test_tx_mode_noop(self):
     """
     With no TX driver, set_transmitting is a noop.
     
     This was chosen as the most robust handling of the erroneous operation.
     """
     d = Device(rx_driver=StubRXDriver())
     d.set_transmitting(True)
     d.set_transmitting(False)
Esempio n. 2
0
 def test_tx_mode_noop(self):
     """
     With no TX driver, set_transmitting is a noop.
     
     This was chosen as the most robust handling of the erroneous operation.
     """
     d = Device(rx_driver=StubRXDriver())
     d.set_transmitting(True)
     d.set_transmitting(False)
Esempio n. 3
0
 def test_tx_mode_actual(self):
     log = []
     txd = _TestTXDriver(log)
     d = Device(rx_driver=_TestRXDriver(), tx_driver=txd)
     def midpoint_hook():
         log.append('H')
     # Either TX driver receives the hook (!= case) or the hook is called directly (== case)
     d.set_transmitting(True, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook)])
     d.set_transmitting(True, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H'])
     d.set_transmitting(False, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H', (False, midpoint_hook)])
     d.set_transmitting(False, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H', (False, midpoint_hook), 'H'])
Esempio n. 4
0
 def test_tx_mode_actual(self):
     log = []
     txd = _TestTXDriver(log)
     d = Device(rx_driver=_TestRXDriver(), tx_driver=txd)
     def midpoint_hook():
         log.append('H')
     # Either TX driver receives the hook (!= case) or the hook is called directly (== case)
     d.set_transmitting(True, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook)])
     d.set_transmitting(True, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H'])
     d.set_transmitting(False, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H', (False, midpoint_hook)])
     d.set_transmitting(False, midpoint_hook)
     self.assertEqual(log, [(True, midpoint_hook), 'H', (False, midpoint_hook), 'H'])