issue #477: stop using fork in service_test.

issue510
David Wilson 6 years ago
parent f1a712fad3
commit 9d5b3d9e02

@ -38,21 +38,21 @@ def call_service_in(context, service_name, method_name):
class ActivationTest(testlib.RouterMixin, testlib.TestCase): class ActivationTest(testlib.RouterMixin, testlib.TestCase):
def test_parent_can_activate(self): def test_parent_can_activate(self):
l1 = self.router.fork() l1 = self.router.local()
counter, id_ = l1.call_service(MyService, 'get_id') counter, id_ = l1.call_service(MyService, 'get_id')
self.assertEquals(1, counter) self.assertEquals(1, counter)
self.assertTrue(isinstance(id_, int)) self.assertTrue(isinstance(id_, int))
def test_sibling_cannot_activate_framework(self): def test_sibling_cannot_activate_framework(self):
l1 = self.router.fork() l1 = self.router.local()
l2 = self.router.fork() l2 = self.router.local()
exc = self.assertRaises(mitogen.core.CallError, exc = self.assertRaises(mitogen.core.CallError,
lambda: l2.call(call_service_in, l1, MyService2.name(), 'get_id')) lambda: l2.call(call_service_in, l1, MyService2.name(), 'get_id'))
self.assertTrue(mitogen.core.Router.refused_msg in exc.args[0]) self.assertTrue(mitogen.core.Router.refused_msg in exc.args[0])
def test_sibling_cannot_activate_service(self): def test_sibling_cannot_activate_service(self):
l1 = self.router.fork() l1 = self.router.local()
l2 = self.router.fork() l2 = self.router.local()
l1.call_service(MyService, 'get_id') # force framework activation l1.call_service(MyService, 'get_id') # force framework activation
capture = testlib.LogCapturer() capture = testlib.LogCapturer()
capture.start() capture.start()
@ -65,7 +65,7 @@ class ActivationTest(testlib.RouterMixin, testlib.TestCase):
self.assertTrue(msg in exc.args[0]) self.assertTrue(msg in exc.args[0])
def test_activates_only_once(self): def test_activates_only_once(self):
l1 = self.router.fork() l1 = self.router.local()
counter, id_ = l1.call_service(MyService, 'get_id') counter, id_ = l1.call_service(MyService, 'get_id')
counter2, id_2 = l1.call_service(MyService, 'get_id') counter2, id_2 = l1.call_service(MyService, 'get_id')
self.assertEquals(1, counter) self.assertEquals(1, counter)
@ -75,16 +75,16 @@ class ActivationTest(testlib.RouterMixin, testlib.TestCase):
class PermissionTest(testlib.RouterMixin, testlib.TestCase): class PermissionTest(testlib.RouterMixin, testlib.TestCase):
def test_sibling_unprivileged_ok(self): def test_sibling_unprivileged_ok(self):
l1 = self.router.fork() l1 = self.router.local()
l1.call_service(MyService, 'get_id') l1.call_service(MyService, 'get_id')
l2 = self.router.fork() l2 = self.router.local()
self.assertEquals('unprivileged!', self.assertEquals('unprivileged!',
l2.call(call_service_in, l1, MyService.name(), 'unprivileged_op')) l2.call(call_service_in, l1, MyService.name(), 'unprivileged_op'))
def test_sibling_privileged_bad(self): def test_sibling_privileged_bad(self):
l1 = self.router.fork() l1 = self.router.local()
l1.call_service(MyService, 'get_id') l1.call_service(MyService, 'get_id')
l2 = self.router.fork() l2 = self.router.local()
capture = testlib.LogCapturer() capture = testlib.LogCapturer()
capture.start() capture.start()
try: try:

Loading…
Cancel
Save