Beispiel #1
0
    def test_on_home_works(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()
        self.assertTrue(observable.add_listener(listener))

        observable._notify_listeners("home")
        self.assertTrue(listener.on_home_notified)
    def test_on_home_works(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()
        self.assertTrue(observable.add_listener(listener))

        observable._notify_listeners("home")
        self.assertTrue(listener.on_home_notified)
Beispiel #3
0
    def test_on_move_works(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()
        self.assertTrue(observable.add_listener(listener))

        observable._notify_listeners("move", 1, 2)
        self.assertTrue(listener.on_move_notified)
        self.assertEqual(listener.on_move_notified[0], 1)
        self.assertEqual(listener.on_move_notified[1], 2)
    def test_on_move_works(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()
        self.assertTrue(observable.add_listener(listener))

        observable._notify_listeners("move", 1, 2)
        self.assertTrue(listener.on_move_notified)
        self.assertEqual(listener.on_move_notified[0], 1)
        self.assertEqual(listener.on_move_notified[1], 2)
Beispiel #5
0
    def test_add_listener_bad(self):
        observable = CoreXYEventObservable()

        self.assertRaises(TypeError, observable.add_listener,
                          "This is not an observer")
        self.assertFalse(observable.listeners)
Beispiel #6
0
    def test_add_listener(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()

        self.assertTrue(observable.add_listener(listener))
        self.assertEqual(len(observable.listeners), 1)
    def test_add_listener(self):
        listener = MockupCoreXYEventListener()
        observable = CoreXYEventObservable()

        self.assertTrue(observable.add_listener(listener))
        self.assertEqual(len(observable.listeners), 1)