def test_Event_CallIngSubscribeWithKwargs_AddAListenerWithKwargs(self): event = Event() event.subscribe("listener1", kwarg1="kwarg1_value", kwarg2="kwarg2_value") self.assertEquals(event.listeners["listener1"], Listener("listener1", CallArgs(kwargs={"kwarg1": "kwarg1_value", "kwarg2" : "kwarg2_value"})))
def test_Event_CreateAnEventWithListener_GetListernerReturnsSameValue(self): event = Event.with_listerners([Listener("listener1")]) self.assertEquals(event.get_listeners(), [Listener("listener1")])
def test_Event_CallIngUnsubscribe_RemovesAListener(self): event = Event.with_listerners([Listener("listener1")]) event.unsubscribe("listener1") self.assertEquals(event.get_listeners_methods(), [])
def test_Event_WhenAllreadySubscribedCallIngSubscribe_RaisesAnException(self): event = Event.with_listerners([Listener("listener1")]) with self.assertRaises(AllreadySubscribedException): event.subscribe("listener1")
def test_Event_CallIngSubscribeWithArgs_AddAListenerWithArgs(self): event = Event() event.subscribe("listener1", "args1", "arg2") self.assertEquals(event.listeners["listener1"], Listener("listener1", CallArgs(args=("args1", "arg2"))))
def test_Event_CallIngSubscribe_AddAListenerObject(self): event = Event() event.subscribe("listener1") self.assertEquals(event.listeners["listener1"], Listener("listener1"))
def test_Event_NewEventWithListernerArguement_HasListenersGiven(self): event = Event.with_listerners([Listener("listener1")]) listeners = event.get_listeners_methods() self.assertEquals(listeners, ["listener1"])