def test_supply_emit_container_decorator(self): container = fastwire.SignalContainer() class A(fastwire.Wired): @container.supply('test_signal') def connected(self, a): self._a = a a = A() signal = container['test_signal'] self.assertEqual(len(signal._receivers.keys()), 1) val = 5.7 signal.emit(a=val) self.assertEqual(a._a, val)
def test_fn_receive_emit_container(self): container = fastwire.SignalContainer() test = [0] @fastwire.fn_receive('test_signal', container=container) def connected(a): test[0] = a signal = container['test_signal'] self.assertEqual(len(signal._receivers.keys()), 1) val = 5.7 signal.emit(a=val) self.assertEqual(test[0], val)
def test_get_repeated(self): sc = fastwire.SignalContainer() wire_1 = sc.get('this_name') wire_2 = sc.get('this_name') self.assertEqual(wire_1, wire_2)
def test_get(self): sc = fastwire.SignalContainer() wire = sc.get('this_name') self.assertEqual(wire.name, 'this_name')
def test_create_on_demand(self): sc = fastwire.SignalContainer() signal = sc['this_name'] self.assertEqual(signal.name, 'this_name') self.assertEqual(signal.__class__, fastwire.Signal)
def test_named_signal(self): sc = fastwire.SignalContainer() signal = sc.signal('this_name') self.assertEqual(signal.name, 'this_name')
def test_unnamed_signal(self): sc = fastwire.SignalContainer() signal = sc.signal() self.assertEqual(signal.__class__, fastwire.Signal)