def test_hasObserver(self):
     obj = BaseObject()
     notificationObject = NotificationTestObserver()
     notificationCenter = NotificationCenter()
     obj._dispatcher = weakref.ref(notificationCenter)
     obj.dispatcher.addObserver(observer=notificationObject,
                                methodName="notificationCallback",
                                notification="BaseObject.Changed",
                                observable=obj)
     self.assertTrue(
         obj.hasObserver(observer=notificationObject,
                         notification="BaseObject.Changed"))
Beispiel #2
0
 def test_hasObserver(self):
     obj = BaseObject()
     notificationObject = NotificationTestObserver()
     notificationCenter = NotificationCenter()
     obj._dispatcher = weakref.ref(notificationCenter)
     obj.dispatcher.addObserver(observer=notificationObject,
                                methodName="notificationCallback",
                                notification="BaseObject.Changed",
                                observable=obj)
     self.assertTrue(
         obj.hasObserver(observer=notificationObject,
                         notification="BaseObject.Changed")
     )
 def test_addObserver(self):
     obj = BaseObject()
     notificationObject = NotificationTestObserver()
     notificationCenter = NotificationCenter()
     obj._dispatcher = weakref.ref(notificationCenter)
     obj.addObserver(observer=notificationObject,
                     methodName="notificationCallback",
                     notification="BaseObject.Changed",
                     identifier="test")
     self.assertTrue(
         obj.dispatcher.hasObserver(observer=notificationObject,
                                    notification="BaseObject.Changed",
                                    observable=obj))
     expected = [
         dict(observer=notificationObject,
              notification="BaseObject.Changed",
              observable=obj,
              identifier="test")
     ]
     result = obj.findObservations()
     self.assertEqual(expected, result)
 def test_dispatcher(self):
     notificationCenter = NotificationCenter()
     obj = BaseObject()
     obj._dispatcher = weakref.ref(notificationCenter)
     self.assertEqual(obj.dispatcher, notificationCenter)
Beispiel #5
0
 def test_dispatcher(self):
     notificationCenter = NotificationCenter()
     obj = BaseObject()
     obj._dispatcher = weakref.ref(notificationCenter)
     self.assertEqual(obj.dispatcher, notificationCenter)