Exemplo n.º 1
0
    def test_reactorSelectionMixin(self):
        """
        Test that the reactor selected is installed as soon as possible, ie
        when the option is parsed.
        """
        executed = []
        INSTALL_EVENT = 'reactor installed'
        SUBCOMMAND_EVENT = 'subcommands loaded'

        class ReactorSelectionOptions(usage.Options,
                                      app.ReactorSelectionMixin):
            def subCommands(self):
                executed.append(SUBCOMMAND_EVENT)
                return [('subcommand', None, lambda: self, 'test subcommand')]

            subCommands = property(subCommands)

        global install

        def install():
            executed.append(INSTALL_EVENT)

        self.pluginResults = [
            reactors.Reactor('fakereactortest', __name__, 'described')
        ]

        options = ReactorSelectionOptions()
        options.parseOptions(['--reactor', 'fakereactortest', 'subcommand'])
        self.assertEqual(executed[0], INSTALL_EVENT)
        self.assertEqual(executed.count(INSTALL_EVENT), 1)
Exemplo n.º 2
0
    def test_reactorInstallation(self):
        """
        Test that L{reactors.Reactor.install} loads the correct module and
        calls its install attribute.
        """
        installed = []
        global install

        def install():
            installed.append(True)

        installer = reactors.Reactor('fakereactortest', __name__, 'described')
        installer.install()
        self.assertEqual(installed, [True])
Exemplo n.º 3
0
 def test_reactorInstallation(self):
     """
     Test that L{reactors.Reactor.install} loads the correct module and
     calls its install attribute.
     """
     installed = []
     def install():
         installed.append(True)
     fakeReactor = FakeReactor(install,
                               'fakereactortest', __name__, 'described')
     modules = {'fakereactortest': fakeReactor}
     self.replaceSysModules(modules)
     installer = reactors.Reactor('fakereactor', 'fakereactortest', 'described')
     installer.install()
     self.assertEqual(installed, [True])
Exemplo n.º 4
0
    def test_installReactor(self):
        """
        Test that the L{reactors.installReactor} function correctly installs
        the specified reactor.
        """
        installed = []
        global install

        def install():
            installed.append(True)

        name = 'fakereactortest'
        package = __name__
        description = 'description'
        self.pluginResults = [reactors.Reactor(name, package, description)]
        reactors.installReactor(name)
        self.assertEqual(installed, [True])
Exemplo n.º 5
0
    def test_getPluginReactorTypes(self):
        """
        Test that reactor plugins are returned from L{getReactorTypes}
        """
        name = "fakereactortest"
        package = __name__ + ".fakereactor"
        description = "description"
        self.pluginResults = [reactors.Reactor(name, package, description)]
        reactorTypes = reactors.getReactorTypes()

        self.assertEqual(self.pluginCalls, [(reactors.IReactorInstaller, None)])

        for r in reactorTypes:
            if r.shortName == name:
                self.assertEqual(r.description, description)
                break
        else:
            self.fail("Reactor plugin not present in getReactorTypes() result")