Beispiel #1
0
    def test_veto_stopping(self):
        """ veto stopping """

        application = TestApplication()

        # This listener will veto the 'stopping' event.
        application.on_trait_change(vetoer, 'stopping')

        tracker = EventTracker(subscriptions=[(
            application,
            'starting'), (application,
                          'started'), (application,
                                       'stopping'), (application, 'stopped')])

        # Start the application.
        started = application.start()
        self.assertEqual(['starting', 'started'], tracker.event_names)
        self.assertEqual(True, started)

        # Stop the application.
        stopped = application.stop()
        self.assertEqual(False, stopped)
        self.assertTrue('stopped' not in tracker.event_names)

        return
    def test_no_plugins(self):
        """ no plugins """

        application = TestApplication()

        tracker = EventTracker(
            subscriptions = [
                (application, 'starting'),
                (application, 'started'),
                (application, 'stopping'),
                (application, 'stopped')
            ]
        )

        # Start the application.
        started = application.start()
        self.assertEqual(True, started)
        self.assertEqual(['starting', 'started'], tracker.event_names)

        # Stop the application.
        stopped = application.stop()
        self.assertEqual(True, stopped)
        self.assertEqual(
            ['starting', 'started', 'stopping', 'stopped'], tracker.event_names
        )
Beispiel #3
0
    def test_veto_starting(self):
        """ veto starting """

        application = TestApplication()

        # This listener will veto the 'starting' event.
        application.on_trait_change(vetoer, "starting")

        tracker = EventTracker(subscriptions=[
            (application, "starting"),
            (application, "started"),
            (application, "stopping"),
            (application, "stopped"),
        ])

        # Start the application.
        started = application.start()
        self.assertEqual(False, started)
        self.assertTrue("started" not in tracker.event_names)