def test_repr_events(self): hub = Hub() hub.readers = {6: Mock(), 7: Mock(), 8: Mock()} hub.writers = {9: Mock()} for value in list(hub.readers.values()) + list(hub.writers.values()): value.__name__ = "mock" self.assertTrue(hub.repr_events([(6, READ), (7, ERR), (8, READ | ERR), (9, WRITE), (10, 13213)]))
def test_repr_active(self): hub = Hub() hub.readers = {1: Mock(), 2: Mock()} hub.writers = {3: Mock(), 4: Mock()} for value in list(hub.readers.values()) + list(hub.writers.values()): value.__name__ = "mock" self.assertTrue(hub.repr_active())
def test_repr_active(self): hub = Hub() hub.readers = {1: Mock(), 2: Mock()} hub.writers = {3: Mock(), 4: Mock()} for value in list(hub.readers.values()) + list(hub.writers.values()): value.__name__ = 'mock' self.assertTrue(hub.repr_active())
def test_callback_for(self): hub = Hub() reader, writer = Mock(), Mock() hub.readers = {6: reader} hub.writers = {7: writer} self.assertEqual(hub._callback_for(6, READ), reader) self.assertEqual(hub._callback_for(7, WRITE), writer) with self.assertRaises(KeyError): hub._callback_for(6, WRITE) self.assertEqual(hub._callback_for(6, WRITE, "foo"), "foo")
def test_callback_for(self): hub = Hub() reader, writer = Mock(), Mock() hub.readers = {6: reader} hub.writers = {7: writer} self.assertEqual(callback_for(hub, 6, READ), reader) self.assertEqual(callback_for(hub, 7, WRITE), writer) with self.assertRaises(KeyError): callback_for(hub, 6, WRITE) self.assertEqual(callback_for(hub, 6, WRITE, 'foo'), 'foo')
def test_repr_events(self): hub = Hub() hub.readers = {6: Mock(), 7: Mock(), 8: Mock()} hub.writers = {9: Mock()} for value in list(hub.readers.values()) + list(hub.writers.values()): value.__name__ = 'mock' self.assertTrue(hub.repr_events([ (6, READ), (7, ERR), (8, READ | ERR), (9, WRITE), (10, 13213), ]))