Exemplo n.º 1
0
class HAAgentProcessControlMockTest(PyonTestCase):

    def setUp(self):
        pd_name = "fakepd"
        resource_registry = "fakerr"
        service_id = "fakeservice"
        self.control = HAProcessControl(pd_name, resource_registry, service_id)

    def test_broken_callback(self):
        event = Mock()

        def raises_socket_error(e):
            # Not derived from Exception
            import socket
            raise socket.error("err")

        def raises_exception(e):
            raise Exception("something")

        def raises_systemexit(e):
            raise SystemExit("something")

        self.control._inner_event_callback = raises_socket_error
        self.control._event_callback(event)

        self.control._inner_event_callback = raises_exception
        self.control._event_callback(event)

        self.control._inner_event_callback = raises_systemexit
        self.assertRaises(SystemExit, self.control._event_callback, event)
Exemplo n.º 2
0
class HAAgentProcessControlMockTest(PyonTestCase):
    def setUp(self):
        pd_name = "fakepd"
        resource_registry = "fakerr"
        service_id = "fakeservice"
        self.control = HAProcessControl(pd_name, resource_registry, service_id)

    def test_broken_callback(self):
        event = Mock()

        def raises_socket_error(e):
            # Not derived from Exception
            import socket
            raise socket.error("err")

        def raises_exception(e):
            raise Exception("something")

        def raises_systemexit(e):
            raise SystemExit("something")

        self.control._inner_event_callback = raises_socket_error
        self.control._event_callback(event)

        self.control._inner_event_callback = raises_exception
        self.control._event_callback(event)

        self.control._inner_event_callback = raises_systemexit
        self.assertRaises(SystemExit, self.control._event_callback, event)
Exemplo n.º 3
0
 def setUp(self):
     pd_name = "fakepd"
     resource_registry = "fakerr"
     service_id = "fakeservice"
     self.control = HAProcessControl(pd_name, resource_registry, service_id)
Exemplo n.º 4
0
 def setUp(self):
     pd_name = "fakepd"
     resource_registry = "fakerr"
     service_id = "fakeservice"
     self.control = HAProcessControl(pd_name, resource_registry, service_id)