Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 4
0
 def testRunning(self):
     s = service.Service()
     self.assertFalse(s.running)
     s.startService()
     self.assertTrue(s.running)
     s.stopService()
     self.assertFalse(s.running)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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), [])
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 16
0
 def testCopying(self):
     s = service.Service()
     s.startService()
     s1 = copy.copy(s)
     self.assertFalse(s1.running)
     self.assertTrue(s.running)
Ejemplo n.º 17
0
 def testCopying(self):
     s = service.Service()
     s.startService()
     s1 = copy.copy(s)
     self.assert_(not s1.running)
     self.assert_(s.running)
Ejemplo n.º 18
0
 def testName(self):
     s = service.Service()
     s.setName("hello")
     self.assertEqual(s.name, "hello")
Ejemplo n.º 19
0
 def testDoublyNamedChild(self):
     s = service.Service()
     p = service.MultiService()
     s.setName("hello")
     s.setServiceParent(p)
     self.failUnlessRaises(RuntimeError, s.setName, "lala")
Ejemplo n.º 20
0
 def testService(self):
     self.assert_(service.IService.providedBy(service.Service()))
Ejemplo n.º 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))
Ejemplo n.º 22
0
 def testParent(self):
     s = service.Service()
     p = service.MultiService()
     s.setServiceParent(p)
     self.failUnlessEqual(list(p), [s])
     self.failUnlessEqual(s.parent, p)
Ejemplo n.º 23
0
 def testName(self):
     s = service.Service()
     s.setName("hello")
     self.failUnlessEqual(s.name, "hello")