예제 #1
0
 def testDuplicateNamedChild(self):
     s = service.Service()
     p = service.MultiService()
     s.setName("hello")
     s.setServiceParent(p)
     s = service.Service()
     s.setName("hello")
     self.failUnlessRaises(RuntimeError, s.setServiceParent, p)
예제 #2
0
 def testPrivileged(self):
     s = service.Service()
     def pss():
         s.privilegedStarted = 1
     s.privilegedStartService = pss
     s1 = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     s1.setServiceParent(p)
     p.privilegedStartService()
     self.assert_(s.privilegedStarted)
예제 #3
0
 def testRunningChildren2(self):
     s = service.Service()
     def checkRunning():
         self.assert_(s.running)
     t = service.Service()
     t.stopService = checkRunning
     t.startService = checkRunning
     p = service.MultiService()
     s.setServiceParent(p)
     t.setServiceParent(p)
     p.startService()
     p.stopService()
예제 #4
0
 def testRunning(self):
     s = service.Service()
     self.assertFalse(s.running)
     s.startService()
     self.assertTrue(s.running)
     s.stopService()
     self.assertFalse(s.running)
예제 #5
0
 def testRunning(self):
     s = service.Service()
     self.assert_(not s.running)
     s.startService()
     self.assert_(s.running)
     s.stopService()
     self.assert_(not s.running)
예제 #6
0
 def testSimpleService(self):
     a = DummyApp()
     a.__dict__ = {
         'udpConnectors': [],
         'unixConnectors': [],
         '_listenerDict': {},
         'name': 'dummy',
         'sslConnectors': [],
         'unixPorts': [],
         '_extraListeners': {},
         'sslPorts': [],
         'tcpPorts': [],
         'services': {},
         'gid': 0,
         'tcpConnectors': [],
         'extraConnectors': [],
         'udpPorts': [],
         'extraPorts': [],
         'uid': 0
     }
     s = service.Service()
     s.setName("lala")
     s.setServiceParent(a)
     appl = compat.convert(a)
     services = list(service.IServiceCollection(appl))
     self.assertEqual(len(services), 1)
     s1 = services[0]
     self.assertEqual(s, s1)
예제 #7
0
 def makeService(self, options):
     """
     Take a L{usage.Options} instance and return a
     L{service.IService} provider.
     """
     self.options = options
     self.service = service.Service()
     return self.service
예제 #8
0
 def testNamedChild(self):
     s = service.Service()
     p = service.MultiService()
     s.setName("hello")
     s.setServiceParent(p)
     self.failUnlessEqual(list(p), [s])
     self.failUnlessEqual(s.parent, p)
     self.failUnlessEqual(p.getServiceNamed("hello"), s)
예제 #9
0
 def testDisowning(self):
     s = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     self.assertEqual(list(p), [s])
     self.assertEqual(s.parent, p)
     s.disownServiceParent()
     self.assertEqual(list(p), [])
     self.assertIsNone(s.parent)
예제 #10
0
 def testDisowning(self):
     s = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     self.failUnlessEqual(list(p), [s])
     self.failUnlessEqual(s.parent, p)
     s.disownServiceParent()
     self.failUnlessEqual(list(p), [])
     self.failUnlessEqual(s.parent, None)
예제 #11
0
 def testServices(self):
     s = service.MultiService()
     c = compat.IOldApplication(s)
     ch = service.Service()
     ch.setName("lala")
     ch.setServiceParent(c)
     self.assertEqual(c.getServiceNamed("lala"), ch)
     ch.disownServiceParent()
     self.assertEqual(list(s), [])
예제 #12
0
 def testAddingIntoRunning(self):
     p = service.MultiService()
     p.startService()
     s = service.Service()
     self.assert_(not s.running)
     s.setServiceParent(p)
     self.assert_(s.running)
     s.disownServiceParent()
     self.assert_(not s.running)
예제 #13
0
def setupControlSocket(configuration, director):
    """
    This is for the functionaity that Apple introduced in the patches from its
    Calendar Server project.
    """
    control = service.Service()
    socket = configuration.control.socket
    if socket != None:
        control = internet.UNIXServer(socket, manager.ControlFactory(director))
    control.setName('control')
    return control
예제 #14
0
 def testRunningChildren1(self):
     s = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     self.assert_(not s.running)
     self.assert_(not p.running)
     p.startService()
     self.assert_(s.running)
     self.assert_(p.running)
     p.stopService()
     self.assert_(not s.running)
     self.assert_(not p.running)
예제 #15
0
def setupHostChecker(configuration, director):
    """
    This is the setup for the "bad host check" management task.
    """
    if not configuration.manager.hostCheckEnabled:
        return service.Service()
    checkInterval = configuration.manager.hostCheckInterval
    checkerService = internet.TimerService(checkInterval,
                                           checker.checkBadHosts,
                                           configuration, director)
    checkerService.setName('hostChecker')
    return checkerService
예제 #16
0
 def testCopying(self):
     s = service.Service()
     s.startService()
     s1 = copy.copy(s)
     self.assertFalse(s1.running)
     self.assertTrue(s.running)
예제 #17
0
 def testCopying(self):
     s = service.Service()
     s.startService()
     s1 = copy.copy(s)
     self.assert_(not s1.running)
     self.assert_(s.running)
예제 #18
0
 def testName(self):
     s = service.Service()
     s.setName("hello")
     self.assertEqual(s.name, "hello")
예제 #19
0
 def testDoublyNamedChild(self):
     s = service.Service()
     p = service.MultiService()
     s.setName("hello")
     s.setServiceParent(p)
     self.failUnlessRaises(RuntimeError, s.setName, "lala")
예제 #20
0
 def testService(self):
     self.assert_(service.IService.providedBy(service.Service()))
예제 #21
0
 def testApplicationAsParent(self):
     s = service.Service()
     p = service.Application("")
     s.setServiceParent(p)
     self.failUnlessEqual(list(service.IServiceCollection(p)), [s])
     self.failUnlessEqual(s.parent, service.IServiceCollection(p))
예제 #22
0
 def testParent(self):
     s = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     self.failUnlessEqual(list(p), [s])
     self.failUnlessEqual(s.parent, p)
예제 #23
0
 def testName(self):
     s = service.Service()
     s.setName("hello")
     self.failUnlessEqual(s.name, "hello")