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)
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)
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