Exemplo n.º 1
0
 def test_listenOption(self):
     """
     Listen options.
     """
     o = Options()
     o.parseOptions(["--listen", "4321"])
     self.assertEqual(o["listen"], "4321")
Exemplo n.º 2
0
 def test_listenOption(self):
     """
     Listen options.
     """
     o = Options()
     o.parseOptions(["--listen", "4321"])
     self.assertEqual(o["listen"], "4321")
Exemplo n.º 3
0
 def test_makeService(self):
     """
     makeService creates a service that, when listened upon, creates a Site.
     """
     o = Options()
     o.parseOptions(["--listen", "fake:"])
     thisFakeParser = FakeEndpointParser()
     addFakePluginObject(self, plugins, thisFakeParser)
     service = makeService(o)
     service.startService()
     self.assertEqual(len(thisFakeParser.endpoints), 1)
     endpoints = thisFakeParser.endpoints[0]
     self.assertEqual(len(endpoints.factories), 1)
     factory = endpoints.factories[0]
     self.assertEqual(factory.displayTracebacks, False)
Exemplo n.º 4
0
 def test_makeService(self):
     """
     makeService creates a service that, when listened upon, creates a Site.
     """
     o = Options()
     o.parseOptions(["--listen", "fake:"])
     thisFakeParser = FakeEndpointParser()
     addFakePluginObject(self, plugins, thisFakeParser)
     service = makeService(o)
     service.startService()
     self.assertEqual(len(thisFakeParser.endpoints), 1)
     endpoints = thisFakeParser.endpoints[0]
     self.assertEqual(len(endpoints.factories), 1)
     factory = endpoints.factories[0]
     self.assertEqual(factory.displayTracebacks, False)
Exemplo n.º 5
0
 def get_site(self, options_list):
     """
     Create the service, and get the site that was created.
     """
     o = Options()
     o.parseOptions(options_list)
     thisFakeParser = FakeEndpointParser()
     addFakePluginObject(self, plugins, thisFakeParser)
     service = makeService(o)
     service.startService()
     self.assertEqual(len(thisFakeParser.endpoints), 1)
     endpoints = thisFakeParser.endpoints[0]
     self.assertEqual(len(endpoints.factories), 1)
     factory = endpoints.factories[0]
     return factory
Exemplo n.º 6
0
 def get_site(self, options_list):
     """
     Create the service, and get the site that was created.
     """
     o = Options()
     o.parseOptions(options_list)
     thisFakeParser = FakeEndpointParser()
     addFakePluginObject(self, plugins, thisFakeParser)
     service = makeService(o)
     service.startService()
     self.assertEqual(len(thisFakeParser.endpoints), 1)
     endpoints = thisFakeParser.endpoints[0]
     self.assertEqual(len(endpoints.factories), 1)
     factory = endpoints.factories[0]
     return factory
Exemplo n.º 7
0
    def test_realtime(self):
        """
        The C{--realtime} option specifies that the global reactor ought to be
        used, so Mimic's time can be advanced by the passage of real time.
        """
        o = Options()
        o.parseOptions(["--realtime"])

        class CheckClock(MimicCore):
            @classmethod
            def fromPlugins(cls, clock):
                result = super(CheckClock, cls).fromPlugins(clock)
                CheckClock.clock = clock
                return result
        from mimic import tap
        self.patch(tap, "MimicCore", CheckClock)
        makeService(o)
        # Grab the global reactor just for comparison.
        from twisted.internet import reactor as real_reactor
        self.assertIdentical(CheckClock.clock, real_reactor)
Exemplo n.º 8
0
    def test_realtime(self):
        """
        The C{--realtime} option specifies that the global reactor ought to be
        used, so Mimic's time can be advanced by the passage of real time.
        """
        o = Options()
        o.parseOptions(["--realtime"])

        class CheckClock(MimicCore):
            @classmethod
            def fromPlugins(cls, clock):
                result = super(CheckClock, cls).fromPlugins(clock)
                CheckClock.clock = clock
                return result

        from mimic import tap
        self.patch(tap, "MimicCore", CheckClock)
        makeService(o)
        # Grab the global reactor just for comparison.
        from twisted.internet import reactor as real_reactor
        self.assertIdentical(CheckClock.clock, real_reactor)