def test_register(self): listener_1 = MagicMock() registration_event_listenable_map[int].add_listener(listener_1) listener_2 = MagicMock() registration_event_listenable_map[int].add_listener(listener_2) register(123) update_1 = RegistrationEvent(123, RegistrationEvent.Type.REGISTERED) listener_1.assert_called_once_with(update_1) listener_1.reset_mock() listener_2.assert_called_once_with(update_1) listener_2.reset_mock()
def test_register_can_be_unsubscribed(self): listener_1 = MagicMock() registration_event_listenable_map[int].add_listener(listener_1) listener_2 = MagicMock() registration_event_listenable_map[int].add_listener(listener_2) register(123) update_1 = RegistrationEvent(123, RegistrationEvent.Type.REGISTERED) registration_event_listenable_map[int].remove_listener(listener_2) register(456) unregister(456) listener_2.assert_called_once_with(update_1)