Beispiel #1
0
 def test_addObserver(self):
     obj = BaseObject()
     notificationObject = NotificationTestObserver()
     notificationCenter = NotificationCenter()
     obj._dispatcher = weakref.ref(notificationCenter)
     obj.addObserver(observer=notificationObject,
                     methodName="notificationCallback",
                     notification="BaseObject.Changed")
     self.assertTrue(
         obj.dispatcher.hasObserver(observer=notificationObject,
                                    notification="BaseObject.Changed",
                                    observable=obj)
     )
 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)