def test_already_started(self): """the service starts during the getService if parent already started""" parent = service.AsyncMultiService() self.successResultOf(parent.startService()) r = self.successResultOf(UnderTestSharedService.getService(parent)) self.assertEqual(r.running, 1) # then we stop the parent, and the shared service stops self.successResultOf(parent.stopService()) self.assertEqual(r.running, 0)
def test_startup(self): """the service starts when parent starts and stop""" parent = service.AsyncMultiService() r = yield UnderTestSharedService.getService(parent) self.assertEqual(r.running, 0) yield parent.startService() self.assertEqual(r.running, 1) yield parent.stopService() self.assertEqual(r.running, 0)
def test_startup(self): """the service starts when parent starts and stop""" parent = service.AsyncMultiService() r = self.successResultOf(UnderTestSharedService.getService(parent)) self.assertEqual(r.running, 0) self.successResultOf(parent.startService()) self.assertEqual(r.running, 1) self.successResultOf(parent.stopService()) self.assertEqual(r.running, 0)
def test_creation(self): parent = service.AsyncMultiService() r = yield UnderTestSharedService.getService(parent) r2 = yield UnderTestSharedService.getService(parent) r3 = yield UnderTestSharedService.getService(parent, "arg1") r4 = yield UnderTestSharedService.getService(parent, "arg1") self.assertIdentical(r, r2) self.assertNotIdentical(r, r3) self.assertIdentical(r3, r4) self.assertEqual(len(list(iter(parent))), 2)
def test_already_stopped_last(self): parent = service.AsyncMultiService() o = UnderTestDependentService() o.setServiceParent(parent) self.successResultOf(parent.startService()) self.successResultOf(parent.stopService())
def test_bad_constructor(self): parent = service.AsyncMultiService() self.failureResultOf( UnderTestSharedService.getService(parent, arg2="foo"))
def setUp(self): self.svc = service.AsyncMultiService()
def test_already_stopped_last(self): parent = service.AsyncMultiService() o = UnderTestDependentService() yield o.setServiceParent(parent) yield parent.startService() yield parent.stopService()
def test_bad_constructor(self): parent = service.AsyncMultiService() with self.assertRaises(Exception): yield UnderTestSharedService.getService(parent, arg2="foo")